On Wed, Oct 19, 2022 at 11:56:00AM -0700, Linus Torvalds wrote: > After fixing fortify-string.h to not complain (which was indeed about > strlen() signedness), it turns out a lot were still about 'char', but > not necessarily the <string,h> functions. > > We use 'unsigned char *' for our dentry data, for example, and then you get > > warning: pointer targets in initialization of ‘const unsigned > char *’ from ‘char *’ differ in signedness > > when you do something like > > QSTR_INIT(NULL_FILE_NAME, > > which is simply doing a regular initializer assignment, and wants to > assign a constant string (in this case the constant string "null") to > that "const unsigned char *name". It cannot see that all users of this are okay with ignoring the difference. > That's certainly another example of "why the heck did the compiler > warn about that thing". Because this is a simple warning. It did exactly what it is supposed to -- you are mixing "char" and "unsigned char" here, and in some cases that matters hugely. > You can literally try to compile this one-liner with gcc: > > const unsigned char *c = "p"; > > and it will complain. What a hugely pointless warning. Yes, there are corner cases like this. Please open a PR if you want this fixed. It is UB to (try to) modify string literals (since they can be shared for example), but still they have type "array of (plain) char". This is historical :-/ Segher