According to exec reference, calls to exec (or stack checking vararg functions in general) requires a (char*)NULL
aka 0 at the end of the parameter list. GCC, however, is complaining about the following code
char cmdFullPath[4096]; //yes this 4096 thing is bad coding practice
...
execl(cmdFullPath, (char*)NULL);
//warning: not enough variable arguments to fit a sentinel
Anyone know what's wrong?
That reference says that the prototype is
execl(const char * path, const char * arg, ...)
I read that as 2 parameters + (char*)NULL
something like :
execl(cmdFullPath, (const char*)NULL, (char*)NULL);
from the page:
#include <unistd.h>
int main() {
execl("/bin/ls", "ls", "-l", (char *)NULL);
return 0;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With