diff mbox series

[v5] mmc-utils: Use printf() to extract and print fw version

Message ID 20211130142715.11014-1-oleg@kaa.org.ua
State Superseded
Headers show
Series [v5] mmc-utils: Use printf() to extract and print fw version | expand

Commit Message

Oleh Kravchenko Nov. 30, 2021, 2:27 p.m. UTC
This patch also fixes a compile error with a newer version of GCC:
error: '__builtin_strncpy' output may be truncated copying 8 bytes from
a string of length 511 [-Werror=stringop-truncation]

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
Reviewed-by: Bean Huo <beanhuo@micron.com>
Fixes: 0eea71e4f22a (mmc-utils: Fix for Firmware Version string printing)
---
 mmc_cmds.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

PATCH v5
Updating commit message.
Adding Fixes: 0eea71e4f22a

Comments

Ulf Hansson Dec. 2, 2021, 2:26 p.m. UTC | #1
On Tue, 30 Nov 2021 at 15:27, Oleh Kravchenko <oleg@kaa.org.ua> wrote:
>
> This patch also fixes a compile error with a newer version of GCC:
> error: '__builtin_strncpy' output may be truncated copying 8 bytes from
> a string of length 511 [-Werror=stringop-truncation]
>
> Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
> Reviewed-by: Bean Huo <beanhuo@micron.com>
> Fixes: 0eea71e4f22a (mmc-utils: Fix for Firmware Version string printing)

Applied to git.kernel.org/pub/scm/utils/mmc/mmc-utils.git master, thanks!

Kind regards
Uffe

> ---
>  mmc_cmds.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> PATCH v5
> Updating commit message.
> Adding Fixes: 0eea71e4f22a
>
> diff --git a/mmc_cmds.c b/mmc_cmds.c
> index 73bd32a..e07ec94 100644
> --- a/mmc_cmds.c
> +++ b/mmc_cmds.c
> @@ -1392,7 +1392,6 @@ int do_read_extcsd(int nargs, char **argv)
>         __u32 regl;
>         int fd, ret;
>         char *device;
> -       char lbuf[10];
>         const char *str;
>
>         if (nargs != 2) {
> @@ -1834,9 +1833,7 @@ int do_read_extcsd(int nargs, char **argv)
>         }
>
>         if (ext_csd_rev >= 7) {
> -                memset(lbuf, 0, sizeof(lbuf));
> -               strncpy(lbuf, (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION], 8);
> -               printf("eMMC Firmware Version: %s\n", lbuf);
> +               printf("eMMC Firmware Version: %.8s\n", (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION]);
>                 printf("eMMC Life Time Estimation A [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x%02x\n",
>                         ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]);
>                 printf("eMMC Life Time Estimation B [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x%02x\n",
> --
> 2.32.0
>
diff mbox series

Patch

diff --git a/mmc_cmds.c b/mmc_cmds.c
index 73bd32a..e07ec94 100644
--- a/mmc_cmds.c
+++ b/mmc_cmds.c
@@ -1392,7 +1392,6 @@  int do_read_extcsd(int nargs, char **argv)
 	__u32 regl;
 	int fd, ret;
 	char *device;
-	char lbuf[10];
 	const char *str;
 
 	if (nargs != 2) {
@@ -1834,9 +1833,7 @@  int do_read_extcsd(int nargs, char **argv)
 	}
 
 	if (ext_csd_rev >= 7) {
-                memset(lbuf, 0, sizeof(lbuf));
-		strncpy(lbuf, (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION], 8);
-		printf("eMMC Firmware Version: %s\n", lbuf);
+		printf("eMMC Firmware Version: %.8s\n", (char*)&ext_csd[EXT_CSD_FIRMWARE_VERSION]);
 		printf("eMMC Life Time Estimation A [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]: 0x%02x\n",
 			ext_csd[EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_A]);
 		printf("eMMC Life Time Estimation B [EXT_CSD_DEVICE_LIFE_TIME_EST_TYP_B]: 0x%02x\n",