edid: silence a stringop-overflow warning
PATCH 1/1 edid: silence a stringop-overflow warning
Simplify the code that doesn't need strncpy() since length of string is already computed.
/home/elmarco/src/qemu/hw/display/edid-generate.c: In function 'edid_desc_text':/home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
strncpy((char *)(desc + 5), text, len);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length computed here
len = strlen(text);
^~~~~~~~~~~~cc1: all warnings being treated as errors
--- hw/display/edid-generate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/display/edid-generate.c +1 -1
@@ -165,7 +165,7 @@ static void edid_desc_text(uint8_t *desc, uint8_t type,if (len >12 ) { len =12 ; } -strncpy ((char *)(desc +5 ), text, len); +memcpy (desc +5 , text, len); desc[5 + len] ='\n' ; }
Signature · 1 line
2.19.1.708.g4ede3d42df
Quoted 22 lines · Marc-André Lureau
Simplify the code that doesn't need
strncpy()since length of string is already computed.
/home/elmarco/src/qemu/hw/display/edid-generate.c: In function 'edid_desc_text':/home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]strncpy((char *)(desc + 5), text, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length computed here len = strlen(text); ^~~~~~~~~~~~cc1: all warnings being treated as errors
Signed-off-by Marc-André Lureau <[email protected]>--- hw/display/edid-generate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/display/edid-generate.c +0
-0
hw/display/edid-generate.c static void edid_desc_text(uint8_t *desc, uint8_t type, · line 170
Quoted 7 lines
hw/display/edid-generate.c +1
-1@@ -165,7 +165,7 @@ static void edid_desc_text(uint8_t *desc, uint8_t type,if (len >12 ) { len =12 ; } -strncpy ((char *)(desc +5 ), text, len); +memcpy (desc +5 , text, len); desc[5 + len] ='\n' ; }
Quoted 5 lines · Marc-André Lureau
Simplify the code that doesn't need
strncpy()since length of string is already computed.
/home/elmarco/src/qemu/hw/display/edid-generate.c: In function 'edid_desc_text':/home/elmarco/src/qemu/hw/display/edid-generate.c:168:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
Quoted 8 lines
strncpy((char *)(desc + 5), text, len); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/elmarco/src/qemu/hw/display/edid-generate.c:164:11: note: length computed here len = strlen(text); ^~~~~~~~~~~~cc1: all warnings being treated as errors
Signed-off-by Marc-André Lureau <[email protected]>
queued for 3.1
thanks,
Gerd