Why is there no brief explanations in this code why each function is banned?
Banned C standard library functions in Git source code
91–100 of 329 posts
Re: Banned C standard library functions in Git source code
#92I'm glad to see that setjmp() and longjmp() are still allowed. I'm just kidding by the way. For those C programmers who haven't encountered these before, it is a powerful way to do a "goto" in C. Powerful in the sense that you can jump anywhere, not limited to the same function. If it's used at all these days, it's used for exception handling. More info: https://en.wikipedia.org/wiki/Setjmp.h
Re: Banned C standard library functions in Git source code
#93Earlier quoted context omitted.
You can build coroutines from them, too, which is really cool and useful.
I think you mean fibers, and no you can't.
Re: Banned C standard library functions in Git source code
#94Re: Banned C standard library functions in Git source code
#95Why is there no brief explanations in this code why each function is banned?
A C programmer reading this list knows exactly why they are there. It is not at all a controversial list. Edit: I guess some down voter doesn't believe me but it continues to be true. They are all string functions. Most of them do not take an output buffer size, so a source string exceeding the destination buffer will overflow. Others, like strncpy, take an output buffer size but will not null terminate when exceeded…
Re: Banned C standard library functions in Git source code
#96Earlier quoted context omitted.
Your macro refers to a twice; it might be better as a function.
What has referring to a variable twice got to do with whether it should be a macro or function?
Re: Banned C standard library functions in Git source code
#97That's a surprisingly small list, missing e.g. sscanf / gets / strtok / all the other "usual suspects" at least
I don't see a huge problem with strtok as long as it isn't a multi threaded program. It is not in gets territory which is literally impossible to use correctly.
Re: Banned C standard library functions in Git source code
#98I guess they care too much about portability to use "pragma GCC poison"?
It wouldn't mean breaking things on compilers other than GCC. It would simply add compile-time checks when building with GCC, and would do nothing on other compilers.