Question

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.

Was it helpful?

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.

OTHER TIPS

In C99 (since you use bool) you have the possibility to require a minimum length of a parameter array by adding static like this

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

the signature (if there is such a thing in C) is still that of a pointer parameter, thought.

(And also I don't know of any existing compiler that does something sensible from that information, yet.)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top