Bruno Haible wrote: > Hi Jim or Eric, > > On MacOS X, with "gcc -Wall", I'm seeing this warning: > > gcc -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -MT lchown.o -MD -MP -MF > .deps/lchown.Tpo -c -o lchown.o lchown.c > lchown.c: In function 'rpl_lchown': > lchown.c:73: warning: unused variable 'st' > > Is it ok to apply this as a fix? ... > rpl_lchown (const char *file, uid_t uid, gid_t gid) > { > +# if CHOWN_CHANGE_TIME_BUG > struct stat st; > +# endif > bool stat_valid = false; > int result;
That file is another ugly nest of #ifdefs. I'm glad it stays mostly hidden in gnulib. Instead of adding more #ifdefs, how about just moving that "struct stat st;" line down a few lines so it's within the existing #if CHOWN_CHANGE_TIME_BUG block: int rpl_lchown (const char *file, uid_t uid, gid_t gid) { struct stat st; bool stat_valid = false; int result; # if CHOWN_CHANGE_TIME_BUG if (gid != (gid_t) -1 || uid != (uid_t) -1) { if (lstat (file, &st)) return -1; stat_valid = true; if (!S_ISLNK (st.st_mode)) return chown (file, uid, gid); } # endif Thanks!