X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=cprogs%2Fxacpi-simple.c;h=f2ba491d93adbc41d8773eedf77b4564f90ece13;hb=a6abbeaa21a10dc79344c4c1ce726fe819487f7f;hp=bf0cf7863f82f343c514beb0673e0b09d95e6217;hpb=fa75bccc01b0152bfdd9d64c00f43e41416767de;p=chiark-utils.git diff --git a/cprogs/xacpi-simple.c b/cprogs/xacpi-simple.c index bf0cf78..f2ba491 100644 --- a/cprogs/xacpi-simple.c +++ b/cprogs/xacpi-simple.c @@ -357,7 +357,7 @@ static double total_##f; ALL_ACCUMULATE_FIELDS(Q_VAR) static void acquiredata(void) { - DIR *di; + DIR *di = 0; struct dirent *de; int r; @@ -427,7 +427,7 @@ ALL_PLAIN_ACCUMULATE_FIELDS(Q_ACCUMULATE_PLAIN) } - closedir(di); + if (di) closedir(di); if (debug) { printf("TOTAL:\n"); @@ -467,17 +467,17 @@ static void initacquire(void) { /*---------- argument parsing ----------*/ #define COLOURS \ - C(blue, discharging) \ - C(green, charging) \ - C(cyan, charged) \ - C(lightgrey, notcharging) \ - C(grey, confusing) \ - C(black, normal) \ - C(red, low) \ - C(dimgrey, degraded) \ - C(darkgreen, absent) \ - C(yellow, error) \ - C(white, equilibrium) \ + C(blue, discharging) \ + C(green, charging) \ + C(cyan, charged) \ + C(lightgrey, notcharging) \ + C(grey, confusing) \ + C(black, normal) \ + C(red, low) \ + C(dimgrey, degraded) \ + C(darkgreen, absent) \ + C(yellow, error) \ + C(white, equilibrium) \ GC(remain) \ GC(white) \ GC(empty) @@ -576,7 +576,7 @@ typedef struct { unsigned long lastfg; } Gcstate; -#define C(c,u) static unsigned long pix_##c; +#define C(c,u) static unsigned long pix_##u; #define GC(g) static Gcstate gc_##g; COLOURS #undef C @@ -622,23 +622,23 @@ static void show(void) { int i, leftmost_lit, leftmost_nondeg, beyond, first_beyond; if (!charging_mask) - return show_solid(pix_darkgreen); + return show_solid(pix_absent); if (charging_mask & (1u << CHGST_ERROR)) - return show_solid(pix_yellow); + return show_solid(pix_error); - setbackground(pix_dimgrey); + setbackground(pix_degraded); XClearWindow(disp,win); setforeground(&gc_remain, !(charging_mask & CHGMASK_CHG_DIS) ? (~charging_mask & (1u << CHGST_CHARGED) ? - pix_lightgrey : pix_cyan) : - !(~charging_mask & CHGMASK_CHG_DIS) ? pix_grey : + pix_notcharging : pix_charged) : + !(~charging_mask & CHGMASK_CHG_DIS) ? pix_confusing : charging_mask & (1u<lastfg= gcv.foreground= pix_white; + gc_r->lastfg= gcv.foreground= pix_equilibrium; gc_r->gc= XCreateGC(disp,win, GCFunction|GCLineWidth|GCForeground, &gcv); } @@ -724,15 +724,15 @@ static void initgraphics(int argc, char **argv) { pos_x,pos_y,width,height,0,0,0); cmap= DefaultColormap(disp,screen); -#define C(c,u) colour(&pix_##c, #u "Color"); +#define C(c,u) colour(&pix_##u, #u "Color"); #define GC(g) initgc(&gc_##g); COLOURS #undef C #undef GC - r= XSetWindowBackground(disp,win,pix_dimgrey); + r= XSetWindowBackground(disp,win,pix_degraded); if (!r) fail("init set background"); - lastbackground= pix_dimgrey; + lastbackground= pix_degraded; normal_hints->flags= PWinGravity; normal_hints->win_gravity= gravity; @@ -763,15 +763,9 @@ static void refresh(void) { static void newgeometry(void) { int dummy; - unsigned int udummy, gotwidth, gotheight; Window dummyw; - XGetGeometry(disp,win, &dummyw,&dummy,&dummy, &gotwidth,&gotheight, - &udummy,&udummy); - assert(gotwidth < INT_MAX); - assert(gotheight < INT_MAX); - width = gotwidth; - height = gotheight; + XGetGeometry(disp,win, &dummyw,&dummy,&dummy, &width,&height, &dummy,&dummy); } static void eventloop(void) {