Hi everyone,
I was looking at leftover violations for MISRA Rule 7.4:
'A string literal shall not be assigned to an object unless the object's
type
is "pointer to const-qualified char" '
You can see the referenced violations at [1] and [2].
I think the ones in x86/setup.c can be taken care of either by making an
early return
from cmdline_cook, given that one caller never supplies a NULL cmdline,
while the other
properly takes care of the possibility of returning NULL, afaict.
static char * __init cmdline_cook(char *p, const char *loader_name)
{
- p = p ? : "";
+ if ( p == NULL )
+ return NULL;
or changing the type of "loader" to const char*
void __init noreturn __start_xen(unsigned long mbi_p)
{
- const char *memmap_type = NULL;
- char *cmdline, *kextra, *loader;
+ const char *memmap_type = NULL, *loader = NULL;
+ char *cmdline, *kextra;;
as, as far as I can tell, it's never changed after
loader = (mbi->flags & MBI_LOADERNAME)
? (char *)__va(mbi->boot_loader_name) : "unknown";
However, the one in xen/arch/arm/efi/efi-boot.h
name.s = "xen";
does not look to have a clear resolution
path, therefore I propose to deviate this with a SAF textual deviation,
whose justification
relies on the fact that the string is never modified afterwards.
For the one in arm-uart.c from the discussion, I'm testing possible
solution with no code
changes, but if that doesn't work out, then I'm inclined towards a
deviation, as options
is never modified afterwards.
What do you think?
[1]
https://saas.eclairit.com:3787/fs/var/local/eclair/XEN.ecdf/ECLAIR_normal/arm/for-4.19/ARM64-Set1/376/PROJECT.ecd;/by_service/MC3R1.R7.4.html
[2]
https://saas.eclairit.com:3787/fs/var/local/eclair/XEN.ecdf/ECLAIR_normal/x86_64/staging/X86_64-Set1/376/PROJECT.ecd;/by_service/MC3R1.R7.4.html
--
Nicola Vetrini, BSc
Software Engineer, BUGSENG srl (https://bugseng.com)