add varargchk to io.h to allow use outside pci.c extend %T to be used with tbdf == BUSUNKNOWN without this change BUSUNKNOWN -> type < 0 which results in a negative index with bustypes[]. for example, an ide device could be BUSUNKNOWN or a valid pci or isa device. Reference: /n/sources/patch/applied/tbdffmt Date: Mon Jul 13 04:53:50 CES 2009 Signed-off-by: quanstro@quanstro.net --- /sys/src/9/pc/pci.c Mon Jul 13 04:53:36 2009 +++ /sys/src/9/pc/pci.c Mon Jul 13 04:53:33 2009 @@ -60,7 +60,7 @@ static Lock pcicfglock; static Lock pcicfginitlock; static int pcicfgmode = -1; -static int pcimaxbno = 7; +static int pcimaxbno = 15; static int pcimaxdno; static Pcidev* pciroot; static Pcidev* pcilist; @@ -97,13 +97,12 @@ "XPRESS", }; -#pragma varargck type "T" int - static int tbdffmt(Fmt* fmt) { char *p; - int l, r, type, tbdf; + int l, r; + uint type, tbdf; if((p = malloc(READSTR)) == nil) return fmtstrcpy(fmt, "(tbdfconv)"); @@ -111,13 +110,17 @@ switch(fmt->r){ case 'T': tbdf = va_arg(fmt->args, int); - type = BUSTYPE(tbdf); - if(type < nelem(bustypes)) - l = snprint(p, READSTR, bustypes[type]); - else - l = snprint(p, READSTR, "%d", type); - snprint(p+l, READSTR-l, ".%d.%d.%d", - BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); + if(tbdf == BUSUNKNOWN) + snprint(p, READSTR, "unknown"); + else{ + type = BUSTYPE(tbdf); + if(type < nelem(bustypes)) + l = snprint(p, READSTR, bustypes[type]); + else + l = snprint(p, READSTR, "%d", type); + snprint(p+l, READSTR-l, ".%d.%d.%d", + BUSBNO(tbdf), BUSDNO(tbdf), BUSFNO(tbdf)); + } break; default: --- /sys/src/9/pc/io.h Mon Jul 13 04:53:43 2009 +++ /sys/src/9/pc/io.h Mon Jul 13 04:53:41 2009 @@ -369,3 +369,6 @@ int time; PCMmap mmap[4]; /* maps, last is always for the kernel */ }; + +#pragma varargck type "T" int +#pragma varargck type "T" uint