libc/gen: unused variables

2015-05-20 Thread Adrian Chadd
Hi,

here's a patch against -head that eliminates gcc-4.9 complaining about
set-but-unused variables. It just comments them out for now - are
these okay to eliminate, or is there something else that's
broken/missing?

Thanks!


-adrian

adrian@lucy-11i386:~/work/freebsd/head-embedded/src/lib % svn diff
Index: libc/gen/dlfcn.c
===
--- libc/gen/dlfcn.c(revision 282934)
+++ libc/gen/dlfcn.c(working copy)
@@ -149,10 +149,10 @@
 dl_init_phdr_info(void)
 {
 Elf_Auxinfo *auxp;
-size_t phent;
+//size_t phent;
 unsigned int i;

-phent = 0;
+//phent = 0;
 for (auxp = __elf_aux_vector; auxp-a_type != AT_NULL; auxp++) {
 switch (auxp-a_type) {
 case AT_BASE:
@@ -166,7 +166,7 @@
 (const Elf_Phdr *)auxp-a_un.a_ptr;
 break;
 case AT_PHENT:
-phent = auxp-a_un.a_val;
+//phent = auxp-a_un.a_val;
 break;
 case AT_PHNUM:
 phdr_info.dlpi_phnum = (Elf_Half)auxp-a_un.a_val;
Index: libc/gen/getgrent.c
===
--- libc/gen/getgrent.c(revision 282934)
+++ libc/gen/getgrent.c(working copy)
@@ -207,11 +207,11 @@
 grp_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
 void *cache_mdata)
 {
-char *name;
-gid_t gid;
+//char *name;
+//gid_t gid;
 struct group *grp;
-char *orig_buf;
-size_t orig_buf_size;
+//char *orig_buf;
+//size_t orig_buf_size;

 struct group new_grp;
 size_t desired_size, size, mem_size;
@@ -219,10 +219,10 @@

 switch ((enum nss_lookup_type)cache_mdata) {
 case nss_lt_name:
-name = va_arg(ap, char *);
+//name = va_arg(ap, char *);
 break;
 case nss_lt_id:
-gid = va_arg(ap, gid_t);
+//gid = va_arg(ap, gid_t);
 break;
 case nss_lt_all:
 break;
@@ -232,8 +232,8 @@
 }

 grp = va_arg(ap, struct group *);
-orig_buf = va_arg(ap, char *);
-orig_buf_size = va_arg(ap, size_t);
+//orig_buf = va_arg(ap, char *);
+//orig_buf_size = va_arg(ap, size_t);

 desired_size = _ALIGNBYTES + sizeof(struct group) + sizeof(char *);

@@ -302,8 +302,8 @@
 grp_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap,
 void *cache_mdata)
 {
-char *name;
-gid_t gid;
+//char *name;
+//gid_t gid;
 struct group *grp;
 char *orig_buf;
 size_t orig_buf_size;
@@ -314,10 +314,10 @@

 switch ((enum nss_lookup_type)cache_mdata) {
 case nss_lt_name:
-name = va_arg(ap, char *);
+//name = va_arg(ap, char *);
 break;
 case nss_lt_id:
-gid = va_arg(ap, gid_t);
+//gid = va_arg(ap, gid_t);
 break;
 case nss_lt_all:
 break;
@@ -659,7 +659,7 @@
 NS_FALLBACK_CB(getgroupmembership_fallback)
 { NULL, NULL, NULL }
 };
-int rv;
+//int rv;

 assert(uname != NULL);
 /* groups may be NULL if just sizing when invoked with maxgrp = 0 */
@@ -666,7 +666,9 @@
 assert(grpcnt != NULL);

 *grpcnt = 0;
-rv = _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
+//rv = _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
+/* XXX TODO: check rv? */
+(void) _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
 defaultsrc, uname, agroup, groups, maxgrp, grpcnt);

 /* too many groups found? */
Index: libc/gen/getpwent.c
===
--- libc/gen/getpwent.c(revision 282934)
+++ libc/gen/getpwent.c(working copy)
@@ -257,11 +257,11 @@
 pwd_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
 void *cache_mdata)
 {
-char *name;
-uid_t uid;
+//char *name;
+//uid_t uid;
 struct passwd *pwd;
-char *orig_buf;
-size_t orig_buf_size;
+//char *orig_buf;
+//size_t orig_buf_size;

 struct passwd new_pwd;
 size_t desired_size, size;
@@ -269,10 +269,10 @@

 switch ((enum nss_lookup_type)cache_mdata) {
 case nss_lt_name:
-name = va_arg(ap, char *);
+//name = va_arg(ap, char *);
 break;
 case nss_lt_id:
-uid = va_arg(ap, uid_t);
+//uid = va_arg(ap, uid_t);
 break;
 case nss_lt_all:
 break;
@@ -282,8 +282,8 @@
 }

 pwd = va_arg(ap, struct passwd *);
-orig_buf = va_arg(ap, char *);
-orig_buf_size = va_arg(ap, size_t);
+//orig_buf = va_arg(ap, char *);
+//orig_buf_size = va_arg(ap, size_t);

 desired_size = sizeof(struct passwd) + sizeof(char *) +
 strlen(pwd-pw_name) + 1;
@@ -361,8 +361,8 @@
 pwd_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list ap,
 void *cache_mdata)
 {
-char *name;
-uid_t uid;
+//char *name;
+//uid_t uid;
 struct passwd *pwd;
 char *orig_buf;
 size_t 

Re: libc/gen: unused variables

2015-05-20 Thread Konstantin Belousov
On Wed, May 20, 2015 at 12:11:08AM -0700, Adrian Chadd wrote:
 Hi,
 
 here's a patch against -head that eliminates gcc-4.9 complaining about
 set-but-unused variables. It just comments them out for now - are
 these okay to eliminate, or is there something else that's
 broken/missing?
Of course, the patch as posted must not be committed.

For dl_init_phdr_info(), it is acceptable to eliminate AT_PHENT case
and phent local.

I have not looked at the other places.
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: libc/gen: unused variables

2015-05-20 Thread Mark Johnston
On Wed, May 20, 2015 at 12:11:08AM -0700, Adrian Chadd wrote:
 Hi,
 
 here's a patch against -head that eliminates gcc-4.9 complaining about
 set-but-unused variables. It just comments them out for now - are
 these okay to eliminate, or is there something else that's
 broken/missing?

The calls to va_arg() have the side effect of advancing to the next
argument, so it's probably not ok to remove them. Perhaps they can be
changed to ignore the return value?

 
 Thanks!
 
 
 -adrian
 
 adrian@lucy-11i386:~/work/freebsd/head-embedded/src/lib % svn diff
 Index: libc/gen/dlfcn.c
 ===
 --- libc/gen/dlfcn.c(revision 282934)
 +++ libc/gen/dlfcn.c(working copy)
 @@ -149,10 +149,10 @@
  dl_init_phdr_info(void)
  {
  Elf_Auxinfo *auxp;
 -size_t phent;
 +//size_t phent;
  unsigned int i;
 
 -phent = 0;
 +//phent = 0;
  for (auxp = __elf_aux_vector; auxp-a_type != AT_NULL; auxp++) {
  switch (auxp-a_type) {
  case AT_BASE:
 @@ -166,7 +166,7 @@
  (const Elf_Phdr *)auxp-a_un.a_ptr;
  break;
  case AT_PHENT:
 -phent = auxp-a_un.a_val;
 +//phent = auxp-a_un.a_val;
  break;
  case AT_PHNUM:
  phdr_info.dlpi_phnum = (Elf_Half)auxp-a_un.a_val;
 Index: libc/gen/getgrent.c
 ===
 --- libc/gen/getgrent.c(revision 282934)
 +++ libc/gen/getgrent.c(working copy)
 @@ -207,11 +207,11 @@
  grp_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
  void *cache_mdata)
  {
 -char *name;
 -gid_t gid;
 +//char *name;
 +//gid_t gid;
  struct group *grp;
 -char *orig_buf;
 -size_t orig_buf_size;
 +//char *orig_buf;
 +//size_t orig_buf_size;
 
  struct group new_grp;
  size_t desired_size, size, mem_size;
 @@ -219,10 +219,10 @@
 
  switch ((enum nss_lookup_type)cache_mdata) {
  case nss_lt_name:
 -name = va_arg(ap, char *);
 +//name = va_arg(ap, char *);
  break;
  case nss_lt_id:
 -gid = va_arg(ap, gid_t);
 +//gid = va_arg(ap, gid_t);
  break;
  case nss_lt_all:
  break;
 @@ -232,8 +232,8 @@
  }
 
  grp = va_arg(ap, struct group *);
 -orig_buf = va_arg(ap, char *);
 -orig_buf_size = va_arg(ap, size_t);
 +//orig_buf = va_arg(ap, char *);
 +//orig_buf_size = va_arg(ap, size_t);
 
  desired_size = _ALIGNBYTES + sizeof(struct group) + sizeof(char *);
 
 @@ -302,8 +302,8 @@
  grp_unmarshal_func(char *buffer, size_t buffer_size, void *retval, va_list 
 ap,
  void *cache_mdata)
  {
 -char *name;
 -gid_t gid;
 +//char *name;
 +//gid_t gid;
  struct group *grp;
  char *orig_buf;
  size_t orig_buf_size;
 @@ -314,10 +314,10 @@
 
  switch ((enum nss_lookup_type)cache_mdata) {
  case nss_lt_name:
 -name = va_arg(ap, char *);
 +//name = va_arg(ap, char *);
  break;
  case nss_lt_id:
 -gid = va_arg(ap, gid_t);
 +//gid = va_arg(ap, gid_t);
  break;
  case nss_lt_all:
  break;
 @@ -659,7 +659,7 @@
  NS_FALLBACK_CB(getgroupmembership_fallback)
  { NULL, NULL, NULL }
  };
 -int rv;
 +//int rv;
 
  assert(uname != NULL);
  /* groups may be NULL if just sizing when invoked with maxgrp = 0 */
 @@ -666,7 +666,9 @@
  assert(grpcnt != NULL);
 
  *grpcnt = 0;
 -rv = _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
 +//rv = _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
 +/* XXX TODO: check rv? */
 +(void) _nsdispatch(NULL, dtab, NSDB_GROUP, getgroupmembership,
  defaultsrc, uname, agroup, groups, maxgrp, grpcnt);
 
  /* too many groups found? */
 Index: libc/gen/getpwent.c
 ===
 --- libc/gen/getpwent.c(revision 282934)
 +++ libc/gen/getpwent.c(working copy)
 @@ -257,11 +257,11 @@
  pwd_marshal_func(char *buffer, size_t *buffer_size, void *retval, va_list ap,
  void *cache_mdata)
  {
 -char *name;
 -uid_t uid;
 +//char *name;
 +//uid_t uid;
  struct passwd *pwd;
 -char *orig_buf;
 -size_t orig_buf_size;
 +//char *orig_buf;
 +//size_t orig_buf_size;
 
  struct passwd new_pwd;
  size_t desired_size, size;
 @@ -269,10 +269,10 @@
 
  switch ((enum nss_lookup_type)cache_mdata) {
  case nss_lt_name:
 -name = va_arg(ap, char *);
 +//name = va_arg(ap, char *);
  break;
  case nss_lt_id:
 -uid = va_arg(ap, uid_t);
 +//uid = va_arg(ap, uid_t);
  break;
  case nss_lt_all:
  break;
 @@ -282,8 +282,8 @@
  }
 
  pwd = va_arg(ap, struct passwd *);
 -orig_buf = va_arg(ap, char *);
 -orig_buf_size = va_arg(ap, size_t);
 +//orig_buf = va_arg(ap, char 

Re: libc/gen: unused variables

2015-05-20 Thread Craig Rodrigues
On Wed, May 20, 2015 at 12:11 AM, Adrian Chadd adr...@freebsd.org wrote:

 Hi,

 here's a patch against -head that eliminates gcc-4.9 complaining about


I've set up a Jenkins build of trunk using gcc 4.9:

https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc4.9/

That build also keeps track of the number of compiler warnings over time,
so if you manage to reduce the warnings, we should see the trend.

How much of FreeBSD have you been able to compile with gcc 4.9, and on
which platform?

On amd64, I could get a buildkernel and buildworld to work, but I had to
forcibly
skip building sys/boot/i386/boot2 because the generated code is too big:

https://lists.freebsd.org/pipermail/freebsd-toolchain/2015-March/001547.html

--
Craig
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: libc/gen: unused variables

2015-05-20 Thread Adrian Chadd
On 20 May 2015 at 17:30, Craig Rodrigues rodr...@freebsd.org wrote:
 On Wed, May 20, 2015 at 12:11 AM, Adrian Chadd adr...@freebsd.org wrote:

 Hi,

 here's a patch against -head that eliminates gcc-4.9 complaining about


 I've set up a Jenkins build of trunk using gcc 4.9:

 https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc4.9/

 That build also keeps track of the number of compiler warnings over time,
 so if you manage to reduce the warnings, we should see the trend.

 How much of FreeBSD have you been able to compile with gcc 4.9, and on which
 platform?

I get down to a little bit inside libc before I hit unused code warnings.




-adrian
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: libc/gen: unused variables

2015-05-20 Thread Craig Rodrigues
On Wed, May 20, 2015 at 5:53 PM, Adrian Chadd adr...@freebsd.org wrote:

 
  How much of FreeBSD have you been able to compile with gcc 4.9, and on
 which
  platform?

 I get down to a little bit inside libc before I hit unused code warnings.


What platform are you compiling on?  Are you looking at anything else
besides unused code warnings?
In the Jenkins job, I put in the following in make.conf:

# disable -Werror in userland build
NO_WERROR=yes
# disable -Werror in kernel build
WERROR=

With this, I build and get all the warnings:
https://jenkins.freebsd.org/job/FreeBSD_HEAD_amd64_gcc4.9/4/warnings17Result/

If you commit stuff which deals with the warnings, it would be hepful if you
can periodically monitor that Jenkins job and see if the overall warnings
go down.
Thanks.

--
Craig
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org


Re: libc/gen: unused variables

2015-05-20 Thread Adrian Chadd
On 20 May 2015 at 00:50, Konstantin Belousov kostik...@gmail.com wrote:
 On Wed, May 20, 2015 at 12:11:08AM -0700, Adrian Chadd wrote:
 Hi,

 here's a patch against -head that eliminates gcc-4.9 complaining about
 set-but-unused variables. It just comments them out for now - are
 these okay to eliminate, or is there something else that's
 broken/missing?
 Of course, the patch as posted must not be committed.

Absolutely. This patch was more like is this all dead code, or are we
supposed to be checking these fields and we aren't?

 For dl_init_phdr_info(), it is acceptable to eliminate AT_PHENT case
 and phent local.

Would you like to do the elimination, so I don't mess it up? :)

 I have not looked at the other places.

Thanks though!



-adrian
___
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to freebsd-current-unsubscr...@freebsd.org