Skip to content

Commit 1c1801e

Browse files
rettichschnidifabiobaltieri
authored andcommitted
drivers: eeprom: Fix format strings
Building for native_posix_64 exposes faulty format strings. Changes in this commit also ensure that the shell code gets built in CI, thus this kind of problem can not be introduced again later on. Signed-off-by: Reto Schneider <[email protected]>
1 parent b77a52b commit 1c1801e

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

drivers/eeprom/eeprom_shell.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ static int cmd_read(const struct shell *shell, size_t argc, char **argv)
4848
return -EINVAL;
4949
}
5050

51-
shell_print(shell, "Reading %d bytes from EEPROM, offset %d...", len,
51+
shell_print(shell, "Reading %zu bytes from EEPROM, offset %zu...", len,
5252
addr);
5353

5454
for (upto = 0; upto < len; upto += pending) {
@@ -84,7 +84,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char **argv)
8484
len = argc - args_indx.data;
8585

8686
if (len > sizeof(wr_buf)) {
87-
shell_error(shell, "Write buffer size (%d bytes) exceeded",
87+
shell_error(shell, "Write buffer size (%zu bytes) exceeded",
8888
sizeof(wr_buf));
8989
return -EINVAL;
9090
}
@@ -104,7 +104,7 @@ static int cmd_write(const struct shell *shell, size_t argc, char **argv)
104104
return -EINVAL;
105105
}
106106

107-
shell_print(shell, "Writing %d bytes to EEPROM...", len);
107+
shell_print(shell, "Writing %zu bytes to EEPROM...", len);
108108

109109
err = eeprom_write(eeprom, offset, wr_buf, len);
110110
if (err) {
@@ -140,7 +140,7 @@ static int cmd_size(const struct shell *shell, size_t argc, char **argv)
140140
return -EINVAL;
141141
}
142142

143-
shell_print(shell, "%d bytes", eeprom_get_size(eeprom));
143+
shell_print(shell, "%zu bytes", eeprom_get_size(eeprom));
144144
return 0;
145145
}
146146

@@ -173,7 +173,7 @@ static int cmd_fill(const struct shell *shell, size_t argc, char **argv)
173173
return -EINVAL;
174174
}
175175

176-
shell_print(shell, "Writing %d bytes of 0x%02lx to EEPROM...", len,
176+
shell_print(shell, "Writing %zu bytes of 0x%02lx to EEPROM...", len,
177177
pattern);
178178

179179
addr = initial_offset;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ensure EEPROM shell can be compiled
2+
CONFIG_SHELL=y
3+
CONFIG_EEPROM_SHELL=y

samples/drivers/eeprom/sample.yaml

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
sample:
22
name: EEPROM Sample
3-
common:
3+
4+
tests:
5+
sample.drivers.eeprom:
46
tags: eeprom
7+
platform_allow: >
8+
gd32f450i_eval
9+
native_posix
10+
native_posix_64
11+
integration_platforms:
12+
- native_posix_64
513
harness: console
614
harness_config:
715
type: one_line
816
regex:
917
- "Reset the MCU to see the increasing boot counter."
10-
11-
tests:
12-
sample.drivers.eeprom:
18+
sample.drivers.eeprom.shell:
1319
tags: eeprom
14-
platform_allow: native_posix gd32f450i_eval
15-
integration_platforms:
16-
- native_posix
20+
platform_allow: >
21+
gd32f450i_eval
22+
native_posix
23+
native_posix_64
24+
extra_args: OVERLAY_CONFIG=overlay-shell.conf
25+
harness: keyboard
1726
sample.drivers.eeprom.shield.x_nucleo_eeprma2:
1827
tags: eeprom shield
1928
depends_on: arduino_gpio arduino_i2c arduino_spi

samples/drivers/eeprom/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void main(void)
4747
}
4848

4949
eeprom_size = eeprom_get_size(eeprom);
50-
printk("Using eeprom with size of: %d.\n", eeprom_size);
50+
printk("Using eeprom with size of: %zu.\n", eeprom_size);
5151

5252
rc = eeprom_read(eeprom, EEPROM_SAMPLE_OFFSET, &values, sizeof(values));
5353
if (rc < 0) {

0 commit comments

Comments
 (0)