Skip to content
Commit 26384722 authored by Pierre Langlois's avatar Pierre Langlois
Browse files

Fix stringop-truncation GCC9 warning.

GCC9's stringop-truncation warning isn't happy about having the destination and
the bound of a strncpy being equal since the resulting string will not be
NULL-terminated:

~~~
src/aarch64/instrument-aarch64.cc: In constructor ‘vixl::aarch64::Counter::Counter(const char*, vixl::aarch64::CounterType)’:
src/aarch64/instrument-aarch64.cc:35:10: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound 256 equals destination size [-Werror=stringop-truncation]
   35 |   strncpy(name_, name, kCounterNameMaxLength);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~

However, we manually NULL-terminate right after so we're actually fine. It
doesn't hurt to fix the warning though by reducing the bound by 1.

See the third paragraph from
https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Warning-Options.html#index-Wstringop-truncation

Change-Id: I74d37dbe13c0d04da9a24c71bc6ef6a92e8333ce
parent 713116bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment