aux/vga: dont rely on atoi() being able to parse hex

This commit is contained in:
cinap_lenrek 2015-08-03 14:24:29 +02:00
parent d5d6724805
commit fc77a2d3d3
3 changed files with 5 additions and 5 deletions

View file

@ -146,14 +146,14 @@ dbpci(Vga *vga, Ndbtuple *tuple)
Pcidev *pci;
for(t = tuple->entry; t; t = t->entry){
if(strcmp(t->attr, "vid") != 0 || (vid=atoi(t->val)) == 0)
if(strcmp(t->attr, "vid") != 0 || (vid=strtol(t->val, 0, 0)) == 0)
continue;
for(td = t->line; td != t; td = td->line){
if(strcmp(td->attr, "did") != 0)
continue;
if(strcmp(td->val, "*") == 0)
did = 0;
else if((did=atoi(td->val)) == 0)
else if((did=strtol(td->val, 0, 0)) == 0)
continue;
for(pci=nil; pci=pcimatch(pci, vid, did);)
if(pci->ccrb == 3)
@ -273,7 +273,7 @@ dbmonitor(Ndb* db, Mode* mode, char* type, char* size)
strcpy(val, buf);
if(p = ndbgetvalue(db, &s, attr, "", "videobw", nil)){
mode->videobw = atol(p)*1000000UL;
mode->videobw = strtol(p, 0, 0)*1000000UL;
free(p);
}

View file

@ -120,7 +120,7 @@ linear(Vga* vga)
* to set up a new one.
*/
vgactlr("addr", buf);
if(atoi(buf)==0 && (buf[0]!='p' || buf[1]!=' ' || atoi(buf+2)==0)){
if(strtoul(buf, 0, 0)==0 && (buf[0]!='p' || buf[1]!=' ' || strtoul(buf+2, 0, 0)==0)){
sprint(buf, "0x%lux 0x%lux", vga->apz ? vga->apz : vga->vmz, vga->vma);
vgactlw("linear", buf);
vgactlr("addr", buf);

View file

@ -261,7 +261,7 @@ load(Vga* vga, Ctlr* ctlr)
if(vbe == nil)
error("no vesa bios\n");
mode = atoi(dbattr(vga->mode->attr, "id"));
mode = strtol(dbattr(vga->mode->attr, "id"), nil, 0);
scale = dbattr(vga->mode->attr, "scale");
ds = dbattr(vga->mode->attr, "display");
display = ds == nil ? 0 : atoi(ds);