Search code examples
clinuxgccsplint

What is the meaning of this splint warning and what might I be doing wrong?


This is the line of code:

bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[2]);

Running splint 3.1.2 generates this warning:

cpfs.h:21:74: Function parameter times declared as manifest array (size
                 constant is meaningless)
  A formal parameter is declared as an array with size.  The size of the array
  is ignored in this context, since the array formal parameter is treated as a
  pointer. (Use -fixedformalarray to inhibit warning)

Naming the parameter makes no difference.


Solution

  • It means that when you declare the parameter struct timespec const[2], the 2 between the [ and ] is not required. Changing your code to:

    bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[]);
    

    In C/C++, you cannot ask for an array of a certain size as a parameter, because the array is treated like a pointer and pointers don't have sizes.