libc/gen: unused variables

Mark Johnston markj at FreeBSD.org
Wed May 20 17:51:06 UTC 2015


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 at 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 orig_buf_size;
> @@ -372,10 +372,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;
> _______________________________________________
> freebsd-current at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe at freebsd.org"


More information about the freebsd-current mailing list