lsof icon indicating copy to clipboard operation
lsof copied to clipboard

Delete (or shrink) unused variables

Open kloczek opened this issue 6 years ago • 2 comments

  • It would be good to remove all rcsid declarations and other. Currently compilers on optimisation process are removing all unused variables and it only polutes build log.
  • Looks like lsof is not using standard CC, LD, AR, RANLIB variables which makes difficult for example LTO optimisation.
[tkloczko@barrel SPECS]$ rpmbuild -ba lsof.spec --quiet
util.c:42:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   42 | static char *rcsid = "$Id: util.c,v 1.1 2008/04/01 11:56:53 abe Exp $";
      |              ^~~~~
util.c:40:13: warning: 'copyright' defined but not used [-Wunused-variable]
   40 | static char copyright[] =
      |             ^~~~~~~~~
ar: ckkv.o: plugin needed to handle lto object
ar: cvfs.o: plugin needed to handle lto object
ar: dvch.o: plugin needed to handle lto object
ar: fino.o: plugin needed to handle lto object
ar: isfn.o: plugin needed to handle lto object
ar: lkud.o: plugin needed to handle lto object
ar: pdvn.o: plugin needed to handle lto object
ar: prfp.o: plugin needed to handle lto object
ar: ptti.o: plugin needed to handle lto object
ar: rdev.o: plugin needed to handle lto object
ar: regex.o: plugin needed to handle lto object
ar: rmnt.o: plugin needed to handle lto object
ar: rnam.o: plugin needed to handle lto object
ar: rnch.o: plugin needed to handle lto object
ar: rnmh.o: plugin needed to handle lto object
ar: snpf.o: plugin needed to handle lto object
ranlib: liblsof.a(ckkv.o): plugin needed to handle lto object
ranlib: liblsof.a(cvfs.o): plugin needed to handle lto object
ranlib: liblsof.a(dvch.o): plugin needed to handle lto object
ranlib: liblsof.a(fino.o): plugin needed to handle lto object
ranlib: liblsof.a(isfn.o): plugin needed to handle lto object
ranlib: liblsof.a(lkud.o): plugin needed to handle lto object
ranlib: liblsof.a(pdvn.o): plugin needed to handle lto object
ranlib: liblsof.a(prfp.o): plugin needed to handle lto object
ranlib: liblsof.a(ptti.o): plugin needed to handle lto object
ranlib: liblsof.a(rdev.o): plugin needed to handle lto object
ranlib: liblsof.a(regex.o): plugin needed to handle lto object
ranlib: liblsof.a(rmnt.o): plugin needed to handle lto object
ranlib: liblsof.a(rnam.o): plugin needed to handle lto object
ranlib: liblsof.a(rnch.o): plugin needed to handle lto object
ranlib: liblsof.a(rnmh.o): plugin needed to handle lto object
ranlib: liblsof.a(snpf.o): plugin needed to handle lto object
In file included from dstore.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dstore.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dstore.c,v 1.4 2011/09/07 19:07:45 abe Exp $";
      |              ^~~~~
dstore.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from node.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
node.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: node.c,v 1.5 2000/08/01 17:08:05 abe Exp $";
      |              ^~~~~
node.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from store.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
store.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: store.c,v 1.44 2018/02/14 14:20:14 abe Exp $";
      |              ^~~~~
store.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from dfile.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dfile.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dfile.c,v 1.8 2012/04/10 16:39:50 abe Exp abe $";
      |              ^~~~~
dfile.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from dnode.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dnode.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dnode.c,v 1.27 2018/03/26 21:52:29 abe Exp $";
      |              ^~~~~
dnode.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from dmnt.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dmnt.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dmnt.c,v 1.21 2018/02/14 14:26:38 abe Exp $";
      |              ^~~~~
dmnt.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from misc.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
misc.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: misc.c,v 1.29 2018/02/14 14:20:14 abe Exp $";
      |              ^~~~~
misc.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from usage.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
usage.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: usage.c,v 1.33 2018/02/14 14:20:14 abe Exp $";
      |              ^~~~~
usage.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from proc.c:39:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
proc.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: proc.c,v 1.50 2018/02/14 14:20:14 abe Exp $";
      |              ^~~~~
proc.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
print.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: print.c,v 1.56 2018/02/14 14:20:14 abe Exp $";
      |              ^~~~~
print.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from dproc.c:38:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dproc.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dproc.c,v 1.31 2018/03/26 21:52:29 abe Exp $";
      |              ^~~~~
dproc.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
In file included from main.c:41:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
main.c:37:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   37 | static char *rcsid = "$Id: main.c,v 1.59 2018/03/26 21:50:45 abe Exp $";
      |              ^~~~~
main.c:35:13: warning: 'copyright' defined but not used [-Wunused-variable]
   35 | static char copyright[] =
      |             ^~~~~~~~~
arg.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: arg.c,v 1.51 2012/04/10 16:30:06 abe Exp abe $";
      |              ^~~~~
arg.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
dsock.c: In function 'fill_uxpino':
dsock.c:866:7: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  866 |   if (pp = check_unix(pi))
      |       ^~
In file included from dsock.c:39:
At top level:
lsof.h:299:20: warning: 'dummy_utmp' defined but not used [-Wunused-variable]
  299 | static struct utmp dummy_utmp;  /* to get login name length */
      |                    ^~~~~~~~~~
dsock.c:35:14: warning: 'rcsid' defined but not used [-Wunused-variable]
   35 | static char *rcsid = "$Id: dsock.c,v 1.43 2018/03/26 21:52:29 abe Exp $";
      |              ^~~~~
dsock.c:33:13: warning: 'copyright' defined but not used [-Wunused-variable]
   33 | static char copyright[] =
      |             ^~~~~~~~~
dwz: ./usr/bin/lsof-4.93.2-2.fc31.x86_64.debug: Unknown DWARF DW_OP_253
994 blocks

kloczek avatar Jun 22 '19 21:06 kloczek

I wonder how I should do about "copyright".

masatake avatar Jul 06 '19 18:07 masatake

All "rscid"s were deleted. I think "copyright"s should be unified into one global variable.

masatake avatar Nov 24 '19 16:11 masatake