2 ms·
you'd want strlen("_shutdown")+1, since checking without the null-terminator means that you match with strings like '_shutdown123'. It's one of the reasons why
by NikkiA 3y ago
you'd want strlen("_shutdown")+1, since checking without the null-terminator means that you match with strings like '_shutdown123'.
It's one of the reasons why I detest the strcmp warning, as strcmp is perfectly safe given a literal string as a comparison, the comparison will drop out as not matching whenever the first NUL happens, and a literal string acts the same as specifying 'n'. Blind usage of strncmp leads to perhaps even more bugs than blind usage of strcmp.