helper/ioutil: silence gcc-8 on strncpy 31/5631/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Mon, 27 Apr 2020 21:19:14 +0000 (23:19 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 9 May 2020 13:36:56 +0000 (14:36 +0100)
commit4738a55da416176542efa1b554020de275a5b4e5
tree2474addeb568b6e9d6be289e48c643827f624b31
parent8807a5937e5fe5d09828c3e535beafb48e171621
helper/ioutil: silence gcc-8 on strncpy

Starting from version 8, gcc issues a warning if strncpy could be
able to truncate a string (so without adding the zero-termination
char in destination) by copying exactly "size" char from a source
string not shorter than "size".
Such truncation from strncpy could actually be the desired code
behaviour, but the way to silent gcc only locally (without global
disabling with -Wno-stringop-truncation) through pragma has other
side effects on portability.

In current code, the source string is always "eth0", because has
been checked right above. So this is a false positive from gcc,
being always strlen("eth0") < 16, the sizeof(ifreq.ifr_name).

Silent gcc by decrementing the "size" and remove:
error: ‘strncpy’ specified bound 16 equals destination
size [-Werror=stringop-truncation]

This file is only optionally compiled together with ZY1000 driver
with --enable-zy1000 --enable-ioutil. This combination is not
checked in jenkins, so the error passed unnoticed.
Plus, the configure flags above are both deprecated!

Change-Id: I229e66227cfd3513139feeaffa47a6e1ec00767b
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5631
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
src/helper/ioutil.c

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)