Hello,
Mir Immad asked:
Should the analyzer warn for code like this "when open fails" (like strchr does when 'strchr' returns NULL) int fd = open("NOFILE", O_RDONLY); write(fd, "a", 1); because of the bad file descriptor. unless it is written like this: if (!errno) write(fd, "a", 1);
My opinion is yes, in most cases. BTW, the write should fail for a read-only file descriptor.
A case (on Linux) where a check is probably not needed: isint fd=open("/proc/self/exe", O_RDONLY); or int fd=open ("/dev/random", O_RDONLY); done *near the beginning* of main. There are only pathological cases where they won't succeed. I suspect that except for very critical executable, testing such failures is practically useless.
And your analyzer might start from https://github.com/bstarynk/bismon/ or use https://frama-c.com/ <https://frama-c.com/>
PS. My pet project is http://refpersys.org/ (Soon generating code compiled by GCC). It is not GCC related.
-- Basile Starynkevitch<bas...@starynkevitch.net> (only mine opinions / les opinions sont miennes uniquement) 92340 Bourg-la-Reine, France web page: starynkevitch.net/Basile/