diff options
author | Xiongfeng Wang <xiongfeng.wang@linaro.org> | 2018-01-12 15:45:38 +0800 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2018-01-30 18:33:14 +0000 |
commit | cb60610af54b143a74991c70448157baf5bfc345 (patch) | |
tree | cd946b0cd32d485ee5449cd447d6f13455657e55 /drivers/iio/accel | |
parent | a66a4e8e01f3b607a9aa5b5ed9ca588b4c3a962e (diff) | |
download | linux-cb60610af54b143a74991c70448157baf5bfc345.tar.bz2 |
iio: accel: use strlcpy() instead of strncpy()
gcc-8 reports
drivers/iio/accel/st_accel_i2c.c: In function 'st_accel_i2c_probe':
./include/linux/string.h:245:9: warning: '__builtin_strncpy' specified
bound 20 equals destination size [-Wstringop-truncation]
The compiler require that the length of the dest string is greater than
the length we want to copy to make sure the dest string is
nul-terminated. We can just use strlcpy() to avoid this warning.
Signed-off-by: Xiongfeng Wang <xiongfeng.wang@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/accel')
-rw-r--r-- | drivers/iio/accel/st_accel_i2c.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c index 363429b5686c..6bdec8c451e0 100644 --- a/drivers/iio/accel/st_accel_i2c.c +++ b/drivers/iio/accel/st_accel_i2c.c @@ -159,9 +159,8 @@ static int st_accel_i2c_probe(struct i2c_client *client, if ((ret < 0) || (ret >= ST_ACCEL_MAX)) return -ENODEV; - strncpy(client->name, st_accel_id_table[ret].name, + strlcpy(client->name, st_accel_id_table[ret].name, sizeof(client->name)); - client->name[sizeof(client->name) - 1] = '\0'; } else if (!id) return -ENODEV; |