bitsy: replace atoi() calls with strtol() when hex can be expcted

This commit is contained in:
cinap_lenrek 2015-08-03 17:08:33 +02:00
parent 2ef29e10f4
commit 953387d7ba
3 changed files with 9 additions and 8 deletions

View file

@ -1326,7 +1326,8 @@ audiowrite(Chan *c, void *vp, long n, vlong)
if(strcmp(cb->f[i], "reg") == 0) { if(strcmp(cb->f[i], "reg") == 0) {
if(cb->nf < 3) if(cb->nf < 3)
error(Evolume); error(Evolume);
setreg(cb->f[1], atoi(cb->f[2]), cb->nf == 4 ? atoi(cb->f[3]):1); setreg(cb->f[1], strtol(cb->f[2], 0, 0),
cb->nf == 4 ? strtol(cb->f[3], 0, 0):1);
return n0; return n0;
} }
error(Evolume); error(Evolume);

View file

@ -349,7 +349,7 @@ static long
if(cmd->nf > 15) if(cmd->nf > 15)
error(Ebadarg); error(Ebadarg);
for(i = 0; i < cmd->nf; i++) for(i = 0; i < cmd->nf; i++)
data[i] = atoi(cmd->f[i]); data[i] = strtol(cmd->f[i], 0, 0);
switch((ulong)c->qid.path){ switch((ulong)c->qid.path){
case Qled: case Qled:

View file

@ -194,14 +194,14 @@ lcdtweak(Cmdbuf *cmd)
return; return;
if(*cmd->f[0] == 'h') if(*cmd->f[0] == 'h')
lcd->lccr1 = ((Ht-16)<<PPL) lcd->lccr1 = ((Ht-16)<<PPL)
| (atoi(cmd->f[1])<<HSW) | (strtol(cmd->f[1], 0, 0)<<HSW)
| (atoi(cmd->f[2])<<ELW) | (strtol(cmd->f[2], 0, 0)<<ELW)
| (atoi(cmd->f[3])<<BLW); | (strtol(cmd->f[3], 0, 0)<<BLW);
if(*cmd->f[0] == 'v') if(*cmd->f[0] == 'v')
lcd->lccr2 = ((Wid-1)<<LPP) lcd->lccr2 = ((Wid-1)<<LPP)
| (atoi(cmd->f[1])<<VSW) | (strtol(cmd->f[1], 0, 0)<<VSW)
| (atoi(cmd->f[2])<<EFW) | (strtol(cmd->f[2], 0, 0)<<EFW)
| (atoi(cmd->f[3])<<BFW); | (strtol(cmd->f[3], 0, 0)<<BFW);
} }
void void