This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [portability] avoid nested functions


On 09/19/2013 12:38 PM, Mike Frysinger wrote:
> +#define lock_dup_elf() \
> +  ({ \
> +    /* We need wrlock to dup an archive.  */ \
> +    if (ref->kind == ELF_K_AR) \
> +      { \
> +	rwlock_unlock (ref->lock); \
> +	rwlock_wrlock (ref->lock); \
> +      } \
> +    /* Duplicate the descriptor.  */ \
> +    return dup_elf (fildes, cmd, ref); \
> +  })

Careful - the nested function just returned from itself, whereas your
macro will try to return from everything.  But this doesn't compile
anyway, because a return leaves the stmt-expr with a void value:

../../libelf/elf_begin.c: In function ‘elf_begin’:
../../libelf/elf_begin.c:1046:9: error: void value not ignored as it
ought to be
  retval = lock_dup_elf ();
         ^
../../libelf/elf_begin.c:1067:13: error: void value not ignored as it
ought to be
      retval = lock_dup_elf ();
             ^

Just remove the "return", then the dup_elf(...) as the last statement
will become the value of the stmt-expr.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]