mainpostsannouncesoft/projmiscstorage

rant on "Invalid argument"

2020/07/18 5:28 PM (UTC -5) | tildearrow

they should change the name to "Unknown error" or add errinfo().
the reason is because "Invalid argument" is so vague and when I see it, I just am like "but WHAT ARGUMENT!!!"

like I mean this error could mean anything... and it happens more often when using the procfs or sysfs...

i mean, sometimes it means one thing, like say I provided a string instead of an integer, but sometimes it could mean many things!

like in the graphics drivers... it could mean anything from memory allocation failure to initialization failure, and you never know!
sometimes it is in the dmesg, but otherwise it is super cryptic that it forces you to recompile the kernel with debug code to find what generates the EINVAL...

yeah, why not add errinfo()? like this:

perror("could not write");
if (errno==EINVAL) {
fprintf(stderr,"details: %s\n",errinfo());
}

this way you get an insight of what happened, like:

could not write: Invalid argument
details: Syntax error at line 1 pos 1

couldn't you do that?!