]> git.ipfire.org Git - thirdparty/collectd.git/commit
common: Fix compiler warning in unit test.
authorFlorian Forster <octo@collectd.org>
Thu, 21 Dec 2023 11:05:45 +0000 (12:05 +0100)
committerFlorian Forster <octo@collectd.org>
Thu, 21 Dec 2023 11:05:48 +0000 (12:05 +0100)
commite96ff0883e09eaa7275f03ff01077d26ca556b34
tree4f1a1e17f9661c516390e013a80b85f3e27c4169
parent19bf95fe5a6fb35167813e0a570763060dee59a9
common: Fix compiler warning in unit test.

Some compilers complained about using a value that depends on the input for the
size argument passed to `strncpy`. They missed that the size of `buf` also
depends on the source argument and therefore this use is fine.

```
  CC       src/utils/common/common_test.o
../../src/utils/common/common_test.c: In function 'test_parse_values':
../../src/utils/common/common_test.c:316:5: error: 'strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
  316 |     strncpy(buf, cases[i].buffer, buf_sz);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../src/utils/common/common_test.c:314:21: note: length computed here
  314 |     size_t buf_sz = strlen(cases[i].buffer) + 1;
      |                     ^~~~~~~~~~~~~~~~~~~~~~~
```
src/utils/common/common_test.c