Re: libc/gen: unused variables

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Wed, 20 May 2015 17:50:06 +0000
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)
> _at__at_ -149,10 +149,10 _at__at_
>  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:
> _at__at_ -166,7 +166,7 _at__at_
>                  (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)
> _at__at_ -207,11 +207,11 _at__at_
>  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;
> _at__at_ -219,10 +219,10 _at__at_
> 
>      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;
> _at__at_ -232,8 +232,8 _at__at_
>      }
> 
>      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 *);
> 
> _at__at_ -302,8 +302,8 _at__at_
>  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;
> _at__at_ -314,10 +314,10 _at__at_
> 
>      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;
> _at__at_ -659,7 +659,7 _at__at_
>          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 */
> _at__at_ -666,7 +666,9 _at__at_
>      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)
> _at__at_ -257,11 +257,11 _at__at_
>  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;
> _at__at_ -269,10 +269,10 _at__at_
> 
>      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;
> _at__at_ -282,8 +282,8 _at__at_
>      }
> 
>      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;
> _at__at_ -361,8 +361,8 _at__at_
>  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;
> _at__at_ -372,10 +372,10 _at__at_
> 
>      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"
Received on Wed May 20 2015 - 15:51:06 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:57 UTC