drivers/sensors: fix build warning on GCC-12
nuttx/drivers/sensors/wtgahrs2.c: In function ‘wtgahrs2_initialize’: nuttx/drivers/sensors/wtgahrs2.c:545:22: warning: ‘%lx’ directive output may be truncated writing between 1 and 16 bytes into a region of size 14 [-Wformat-truncation=] 545 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)rtdata); | ^~~~~ nuttx/drivers/sensors/wtgahrs2.c:545:25: note: format string is defined here 545 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)rtdata); nuttx/drivers/sensors/wtgahrs2.c:545:22: note: directive argument in the range [1, 18446744073709551615] 545 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)rtdata); | ^~~~~ nuttx/drivers/sensors/wtgahrs2.c:545:3: note: ‘snprintf’ output between 4 and 19 bytes into a destination of size 16 545 | snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)rtdata); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
parent
375959eac1
commit
f49ee08ab4
@ -435,7 +435,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
|
||||
FAR struct wtgahrs2_sensor_s *tmp;
|
||||
struct termios opt;
|
||||
FAR char *argv[2];
|
||||
char arg1[16];
|
||||
char arg1[32];
|
||||
int ret;
|
||||
|
||||
if (!path)
|
||||
@ -542,7 +542,7 @@ int wtgahrs2_initialize(FAR const char *path, int devno)
|
||||
|
||||
wtgahrs2_sendcmd(rtdata, g_wtgahrs2_enable_sensor);
|
||||
|
||||
snprintf(arg1, 16, "0x%" PRIxPTR, (uintptr_t)rtdata);
|
||||
snprintf(arg1, sizeof(arg1), "0x%" PRIxPTR, (uintptr_t)rtdata);
|
||||
argv[0] = arg1;
|
||||
argv[1] = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user