Messages in this thread | | | Subject | stracpy | From | Joe Perches <> | Date | Tue, 20 Aug 2019 17:58:27 -0700 |
| |
On Tue, 2019-08-20 at 17:43 -0700, Linus Torvalds wrote: > On Tue, Aug 20, 2019 at 5:20 PM Joe Perches <joe@perches.com> wrote: > > Umm, btw: have you actually looked at stracpy? > > Yes, Joe, I have. > > What part of "there are now so many of them that no human being can > keep track of them" didn't you see as a problem?
Well, the actual post-conversion uses to stracpy make the old ones (strcpy/strlcpy/strncpy) exceptional uses that can be analyzed quite a bit more easily.
btw: I really don't care what any convenience macro is named.
Most all of the strlcpy and strscpy uses actually _do_ copy to a char array and strscpy is a simple interface that is somewhat frequently misused.
> How many broken string functions are we going to do, adding yet > another one when you notice that the _last_ one wasn't great? > > We never seem to remove the broken ones. We just add yet another one, > and have a never-ending jumble of random letters.
<shrug> Intermediate problems.
> I would seriously suggest doing something like > and > copy_string( dst, dstsize, src, srcsize, FLAGS ); > > where FLAGS migth be "pad" or whatever. Make it return the size of the > resulting string, because while it can be convenient to pass 'dst" on, > it's not useful.
That's simply not convenient for pointers.
Auditing the kernel for those unsized uses is a large scope problem. Even anything that uses PAGE_SIZE sized allocations does sprintf instead of snprintf. Any show_<foo> for instance.
> And then maybe just add the helper macro that turns an array into a > "pointer, size" combination, rather than yet another letter jumble.
Good luck with that when an unsized char pointer is the thing passed to a function.
There are _way_ too many of those already in the kernel. Simple strcpy is already used > 2000 times.
| |