On Wed, Jul 27, 2016 at 08:41:15PM +0200, Nahim El Atmani wrote:
> From: Nahim El Atmani <n...@lse.epita.fr>
> 
> From: Nahim El Atmani <nahim+...@naam.me>

Too many Froms.

> * syscall.c (reallocate_vec): New function.
>   (reallocate_qual): Use it.
>   (find_errno_by_name): New function.
>   (find_scno_by_name): Likewise.

No need to indent.  You can also write
((find_errno_by_name, find_scno_by_name): New functions.

> -static void
> -reallocate_qual(const unsigned int n)
> +static inline void

No need to use "inline" keyword.

> +reallocate_vec(void **vec, size_t size, size_t elt, int n)

The names of arguments are confusing.  In terms of xreallocarray,
"size" is "old_nmemb", "elt" is "size", and "n" is "new_nmemb".

>  {
>       unsigned p;
> -     qualbits_t *qp;
> +     char *ptr;

Why "char *"?  If "vec" has type "void **", then vec[p] has type "void *".

> +
>       for (p = 0; p < SUPPORTED_PERSONALITIES; p++) {
> -             qp = qual_vec[p] = xreallocarray(qual_vec[p], n,
> -                                              sizeof(qualbits_t));
> -             memset(&qp[num_quals], 0, (n - num_quals) * sizeof(qualbits_t));
> +             ptr = vec[p] = xreallocarray(vec[p], n, elt);
> +             memset(ptr + elt * size, 0, (n - size) * elt);
>       }
> +}
> +
> +static inline void

No need to use "inline" keyword.

> +reallocate_qual(const unsigned int n)
> +{
> +     reallocate_vec((void **)qual_vec, num_quals, sizeof(qualbits_t), n);
>       num_quals = n;
>  }
>  
> +static int
> +find_errno_by_name(const char *name)
> +{
> +     unsigned int i;
> +
> +     for (i = 1; i < nerrnos; i++) {
> +             if (errnoent[i] && (strcmp(name, errnoent[i]) == 0))
> +                     return i;
> +     }
> +
> +     return -1;
> +}
> +
> +static int
> +find_scno_by_name(const char *name, unsigned personality)
> +{
> +     unsigned int i;
> +
> +     for (i = 0; i < nsyscall_vec[personality]; i++) {
> +             if (sysent_vec[personality][i].sys_name
> +                 && strcmp(name, sysent_vec[personality][i].sys_name) == 0) {
> +                     return i;
> +             }
> +     }
> +
> +     return -1;
> +}

These static functions are added but never used.  This results to
compilation warnings and --enable-gcc-Werror turns them into errors:

syscall.c:434:1: error: 'find_errno_by_name' defined but not used 
[-Werror=unused-function]
 find_errno_by_name(const char *name)
 ^
syscall.c:447:1: error: 'find_scno_by_name' defined but not used 
[-Werror=unused-function]
 find_scno_by_name(const char *name, unsigned personality)
 ^

Even with subsequent patches applied these compilation warnings/errors
remain unless --enable-fault-injection is specified.


-- 
ldv

Attachment: pgpZUQ9fjdNJW.pgp
Description: PGP signature

------------------------------------------------------------------------------
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to