4 ms·
at the risk of sounding rude, this guy probably only learned C last week. i mean, all but one of his complaints are noise. > k&r function headers unusual, but
by foxhill 12y ago
at the risk of sounding rude, this guy probably only learned C last week. i mean, all but one of his complaints are noise.
> k&r function headers
unusual, but totally valid, even in C99. a minor syntactical difference. not a style i'd use, but no different to the alternative. and if a static analyser would find this confusing, you probably shouldn't use it.
> global variables
i buy this. although your figure of "5" global variables is totally arbitrary. "0, 1, or infinite" principle.
> lol wat?
granted this for loop is arcane, but it's obvious what it does. note that the suggested alternative increments the index at the end of the loop body, etc. might not have been exploited there, but perhaps it's a style used somewhere else where it does matter, and it's been used here to maintain consistency.
regardless, it's probably better to use
const size_t len = strlen(env);
for(size_t i=0; i<len; i++)
//etc
and using an assignment expression in a boolean statement is totally valid.
> no banned functions
at this point i decided the author clearly does not know what he's talking about, and has joined a bandwagon of code-hate.
banned functions. unsafe memory moves. "what if the destination is too small for the result?". urgh. look at the code that was pasted. strcpy, obviously has pitfalls that can easily overwrite random bits of memory. but this code cannot possibly exhibit it. if you want to complain about safe use of strcpy for the functions potential unsafe-ness, well, you may as well argue that C is an unsafe language, as the runtime doesn't catch out-of-bounds accesses, etc.
> where to go from here
if you've got style complaints about bash's source, change it, and submit patches. blog posts like the one posted do not help anyone.