always close fd `i' in readtimezone, even if there's an error. also eliminate a bunch of gotos. Notes: Mon Apr 10 11:20:22 EDT 2006 rsc since the goto can't go away entirely i'm inclined to leave the if()s as they are. it's going to compile into the same code. i did fix the fd leak. thanks. Reference: /n/sources/patch/applied/readtimezone-fd-leak Date: Mon Apr 10 02:48:13 CES 2006 Signed-off-by: geoff@collyer.net Reviewed-by: rsc --- /sys/src/libc/9sys/ctime.c Mon Apr 10 02:46:42 2006 +++ /sys/src/libc/9sys/ctime.c Mon Apr 10 02:46:39 2006 @@ -216,20 +216,13 @@ int i; memset(buf, 0, sizeof(buf)); - i = open("/env/timezone", 0); - if(i < 0) - goto error; - if(read(i, buf, sizeof(buf)) >= sizeof(buf)) - goto error; - close(i); p = buf; - if(rd_name(&p, timezone.stname)) - goto error; - if(rd_long(&p, &timezone.stdiff)) - goto error; - if(rd_name(&p, timezone.dlname)) - goto error; - if(rd_long(&p, &timezone.dldiff)) + i = open("/env/timezone", 0); + if(i < 0 || read(i, buf, sizeof(buf)) >= sizeof(buf) || + rd_name(&p, timezone.stname) || + rd_long(&p, &timezone.stdiff) || + rd_name(&p, timezone.dlname) || + rd_long(&p, &timezone.dldiff)) goto error; for(i=0; i= 0) + close(i); timezone.stdiff = 0; strcpy(timezone.stname, "GMT"); timezone.dlpairs[0] = 0;