[Replicant] [libsamsung-ipc] [PATCH 03/26] tools: ipc-imei: fix printf size_t integer conversion
Denis 'GNUtoo' Carikli
GNUtoo at cyberdimension.org
Mon Mar 28 20:20:17 UTC 2022
Without that fix we have compilation errors:
nv_data-imei.c: In function ‘get_imei’:
nv_data-imei.c:181:12: error: format ‘%d’ expects argument of type
‘int’, but argument 2 has type ‘size_t’ {aka ‘long unsigned int’}
[-Werror=format=]
181 | printf("In addition it is also invalid"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
......
184 | len, IMEI_LENGTH);
| ~~~
| |
| size_t {aka long unsigned int}
nv_data-imei.c:183:14: note: format string is defined here
183 | "%d digits instead of %d.\n",
| ~^
| |
| int
| %ld
nv_data-imei.c:193:12: error: format ‘%d’ expects argument of type
‘int’, but argument 3 has type ‘size_t’ {aka ‘long unsigned int’}
[-Werror=format=]
193 | printf("The '%s' "
| ^~~~~~~~~~~
......
196 | imei->optarg, len, IMEI_LENGTH);
| ~~~
| |
| size_t {aka long unsigned int}
nv_data-imei.c:195:14: note: format string is defined here
195 | "%d digits instead of %d.\n",
| ~^
| |
| int
| %ld
This issue was introduced in commit
1cd1a569bef21ed3bfaeda15fb210ef6fd218152 (tools: Add a new
nv_data-imei tool based on rfs-imei)
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo at cyberdimension.org>
---
tools/nv_data-imei.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/nv_data-imei.c b/tools/nv_data-imei.c
index 2c04079..c5301b7 100644
--- a/tools/nv_data-imei.c
+++ b/tools/nv_data-imei.c
@@ -180,7 +180,7 @@ static int get_imei(struct command *command, void *arg)
imei->optarg);
printf("In addition it is also invalid"
" as it is composed of "
- "%d digits instead of %d.\n",
+ "%zd digits instead of %d.\n",
len, IMEI_LENGTH);
return -EINVAL;
} else if (!str_is_digit) {
@@ -192,7 +192,7 @@ static int get_imei(struct command *command, void *arg)
} else if (!str_len_valid) {
printf("The '%s' "
"IMEI is invalid as it is composed of "
- "%d digits instead of %d.\n",
+ "%zd digits instead of %d.\n",
imei->optarg, len, IMEI_LENGTH);
return -EINVAL;
}
--
2.35.1
More information about the Replicant
mailing list