[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <edd8efd53fadd07992f804cc595c6ae5fdb60e73.camel@perches.com>
Date: Tue, 20 Aug 2019 17:20:43 -0700
From: Joe Perches <joe@...ches.com>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Stephen Rothwell <sfr@...b.auug.org.au>,
Julia Lawall <julia.lawall@...6.fr>,
"Gustavo A. R. Silva" <gustavo@...eddedor.com>,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux@...glegroups.com,
Linux Next Mailing List <linux-next@...r.kernel.org>
Subject: Re: rfc: treewide scripted patch mechanism? (was: Re: [PATCH]
Makefile: Convert -Wimplicit-fallthrough=3 to just -Wimplicit-fallthrough
for clang)QUILT
On Tue, 2019-08-20 at 16:28 -0700, Linus Torvalds wrote:
> On Mon, Aug 19, 2019 at 5:08 PM Joe Perches <joe@...ches.com> wrote:
> > 2: would be Julia Lawall's stracpy change done
> > with coccinelle: (attached)
>
> I'm not actually convinced about stracpy() and friends.
>
> It seems to be yet another badly thought out string interface, and
> there are now so many of them that no human being can keep track of
> them.
>
> The "badly thought out" part is that it (like the original strlcpy
> garbage from BSD) thinks that there is only one size that matters -
> the destination.
>
> Yes, we fixed part of the "source is also limited" with strscpy(). It
> didn't fix the problem with different size limits, but at least it
> fixed the fundamentally broken assumption that the source has no size
> limit at all.
Umm, btw: have you actually looked at stracpy?
It's just a convenience wrapper around strscpy
and dest must be a char array and its size
does not need to be specified as a somewhat
useless argument otherwise prone to misuse.
#define stracpy(dest, src) \
({ \
size_t count = ARRAY_SIZE(dest); \
BUILD_BUG_ON(!(__same_type(dest, char[]) || \
__same_type(dest, unsigned char[]) || \
__same_type(dest, signed char[]))); \
\
strscpy(dest, src, count); \
})
I sent several patches for those misuses.
Powered by blists - more mailing lists