diff options
author | Caio Marcelo de Oliveira Filho <[email protected]> | 2018-07-16 14:06:09 -0700 |
---|---|---|
committer | Caio Marcelo de Oliveira Filho <[email protected]> | 2018-07-18 08:29:51 -0700 |
commit | f836d799f9066adf58f3660626d7aa58c0c9b62e (patch) | |
tree | b29f70d80268cbb1a67c83c8b46529e95e12e81c /src/intel/common | |
parent | 20fcd152a2843f8f55564b2f92aecc4e024386c3 (diff) |
intel/decoder: use snprintf(..., "%s", ...) instead of strncpy
strncpy() doesn't guarantee the terminator NUL, so we would need to
set ourselves. Just use snprintf() instead.
Fixes the warnings
../../src/intel/common/gen_decoder.c: In function ‘iter_decode_field’:
../../src/intel/common/gen_decoder.c:897:7: warning: ‘strncpy’ specified bound 128 equals destination size [-Wstringop-truncation]
strncpy(iter->name, iter->field->name, sizeof(iter->name));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘iter_advance_field’,
inlined from ‘gen_field_iterator_next’ at ../../src/intel/common/gen_decoder.c:1015:9:
../../src/intel/common/gen_decoder.c:844:7: warning: ‘strncpy’ specified bound 128 equals destination size [-Wstringop-truncation]
strncpy(iter->name, iter->field->name, sizeof(iter->name));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Reviewed-by: Anuj Phogat <[email protected]>
Diffstat (limited to 'src/intel/common')
-rw-r--r-- | src/intel/common/gen_decoder.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index bb87192d23c..ec0a486b101 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -841,7 +841,7 @@ iter_advance_field(struct gen_field_iterator *iter) } if (iter->field->name) - strncpy(iter->name, iter->field->name, sizeof(iter->name)); + snprintf(iter->name, sizeof(iter->name), "%s", iter->field->name); else memset(iter->name, 0, sizeof(iter->name)); @@ -894,7 +894,7 @@ iter_decode_field(struct gen_field_iterator *iter) } v; if (iter->field->name) - strncpy(iter->name, iter->field->name, sizeof(iter->name)); + snprintf(iter->name, sizeof(iter->name), "%s", iter->field->name); else memset(iter->name, 0, sizeof(iter->name)); |