[U-Boot] [PATCH] imx: mx6/7 define CONFIG_SYS_VSNPRINTF

From: Peng Fan peng.fan@nxp.com
Define CONFIG_SYS_VSNPRINTF to use snprintf. If not define CONFIG_SYS_VSNPRINTF, snprintf is sprintf.
Report by Coverity: pass string init_val of unknown size to sprintf
Signed-off-by: Peng Fan peng.fan@nxp.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Fabio Estevam fabio.estevam@freescale.com Cc: Adrian Alonso aalonso@freescale.com Cc: Stefano Babic sbabic@denx.de --- include/configs/mx6_common.h | 4 ++++ include/configs/mx7_common.h | 4 ++++ 2 files changed, 8 insertions(+)
diff --git a/include/configs/mx6_common.h b/include/configs/mx6_common.h index 1fd7ce3..1a470a4 100644 --- a/include/configs/mx6_common.h +++ b/include/configs/mx6_common.h @@ -17,6 +17,10 @@ #ifndef __MX6_COMMON_H #define __MX6_COMMON_H
+#ifndef CONFIG_SPL_BUILD +#define CONFIG_SYS_VSNPRINTF +#endif + #ifndef CONFIG_MX6UL #define CONFIG_ARM_ERRATA_743622 #define CONFIG_ARM_ERRATA_751472 diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h index d507fb4..505f6cc 100644 --- a/include/configs/mx7_common.h +++ b/include/configs/mx7_common.h @@ -13,6 +13,10 @@ #include <asm/arch/imx-regs.h> #include <asm/imx-common/gpio.h>
+#ifndef CONFIG_SPL_BUILD +#define CONFIG_SYS_VSNPRINTF +#endif + #ifndef CONFIG_MX7 #define CONFIG_MX7 #endif

On Tue, Jan 12, 2016 at 05:45:24PM +0800, Peng Fan wrote:
From: Peng Fan peng.fan@nxp.com
Define CONFIG_SYS_VSNPRINTF to use snprintf. If not define CONFIG_SYS_VSNPRINTF, snprintf is sprintf.
Report by Coverity: pass string init_val of unknown size to sprintf
Signed-off-by: Peng Fan peng.fan@nxp.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Fabio Estevam fabio.estevam@freescale.com Cc: Adrian Alonso aalonso@freescale.com Cc: Stefano Babic sbabic@denx.de
I'm not sure how I feel about fixing this range of issues only for certain targets. I need to do some global building here and see what happens.

Hi Tom,
On Wed, Jan 13, 2016 at 02:57:00PM -0500, Tom Rini wrote:
On Tue, Jan 12, 2016 at 05:45:24PM +0800, Peng Fan wrote:
From: Peng Fan peng.fan@nxp.com
Define CONFIG_SYS_VSNPRINTF to use snprintf. If not define CONFIG_SYS_VSNPRINTF, snprintf is sprintf.
Report by Coverity: pass string init_val of unknown size to sprintf
Signed-off-by: Peng Fan peng.fan@nxp.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Fabio Estevam fabio.estevam@freescale.com Cc: Adrian Alonso aalonso@freescale.com Cc: Stefano Babic sbabic@denx.de
I'm not sure how I feel about fixing this range of issues only for certain targets. I need to do some global building here and see what happens.
With CONFIG_SYS_VSNPRINTF defined, image size may be bigger. So here, I use #ifdef CONFIG_SPL_BUILD.
Ok, wait for your further comments on this.
Regards, Peng.
-- Tom

On Wed, Jan 13, 2016 at 7:57 PM, Tom Rini trini@konsulko.com wrote:
On Tue, Jan 12, 2016 at 05:45:24PM +0800, Peng Fan wrote:
From: Peng Fan peng.fan@nxp.com
Define CONFIG_SYS_VSNPRINTF to use snprintf. If not define CONFIG_SYS_VSNPRINTF, snprintf is sprintf.
Report by Coverity: pass string init_val of unknown size to sprintf
Signed-off-by: Peng Fan peng.fan@nxp.com Cc: Peter Robinson pbrobinson@gmail.com Cc: Fabio Estevam fabio.estevam@freescale.com Cc: Adrian Alonso aalonso@freescale.com Cc: Stefano Babic sbabic@denx.de
I'm not sure how I feel about fixing this range of issues only for certain targets. I need to do some global building here and see what happens.
I'm not sure it's 100% the same, not had time to look closely, but it looks similar to a build regression I'm seeing in the 2016.01 GA that wasn't in RC4. Snippet below, or full build log at [1]
Peter
gcc -Wp,-MD,spl/lib/.strto.o.d -nostdinc -isystem /usr/lib/gcc/armv7hl-redhat-linux-gnueabi/5.3.1/include -Iinclude -I/builddir/build/BUILD/u-boot-2016.01/include -I/builddir/build/BUILD/u-boot-2016.01/arch/arm/include -include /builddir/build/BUILD/u-boot-2016.01/include/linux/kconfig.h -I/builddir/build/BUILD/u-boot-2016.01/spl/lib -Ispl/lib -D__KERNEL__ -D__UBOOT__ -DCONFIG_SYS_TEXT_BASE=0x00100000 -DCONFIG_SPL_BUILD -Wall -Wstrict-prototypes -Wno-format-security -fno-builtin -ffreestanding -Os -fno-stack-protector -fno-delete-null-pointer-checks -g -fstack-usage -Wno-format-nonliteral -Werror=date-time -ffunction-sections -fdata-sections -D__ARM__ -Wa,-mimplicit-it=always -mthumb -mthumb-interwork -mabi=aapcs-linux -mno-unaligned-access -ffunction-sections -fdata-sections -fno-common -ffixed-r9 -msoft-float -pipe -march=armv7-a -I/builddir/build/BUILD/u-boot-2016.01/arch/arm/mach-rockchip/include -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(strto)" -D"KBUILD_MODNAME=KBUILD_STR(strto)" -c -o spl/lib/strto.o /builddir/build/BUILD/u-boot-2016.01/lib/strto.c ld.bfd -r -o spl/lib/built-in.o spl/lib/libfdt/built-in.o spl/lib/fdtdec_common.o spl/lib/fdtdec.o spl/lib/hashtable.o spl/lib/errno.o spl/lib/display_options.o spl/lib/crc32.o spl/lib/ctype.o spl/lib/div64.o spl/lib/hang.o spl/lib/linux_compat.o spl/lib/linux_string.o spl/lib/membuff.o spl/lib/slre.o spl/lib/string.o spl/lib/time.o spl/lib/uuid.o spl/lib/tiny-printf.o spl/lib/panic.o spl/lib/strto.o (cd spl && ld.bfd -T u-boot-spl.lds --gc-sections -Bstatic --gc-sections -Ttext 0xff704004 arch/arm/cpu/armv7/start.o --start-group arch/arm/mach-rockchip/built-in.o arch/arm/cpu/armv7/built-in.o arch/arm/cpu/built-in.o arch/arm/lib/built-in.o board/google/chromebook_jerry/built-in.o board/google/common/built-in.o common/spl/built-in.o common/init/built-in.o common/built-in.o drivers/built-in.o dts/built-in.o fs/built-in.o lib/built-in.o --end-group arch/arm/lib/eabi_compat.o arch/arm/lib/lib.a -Map u-boot-spl.map -o u-boot-spl) drivers/built-in.o: In function `spi_flash_probe_bus_cs': /builddir/build/BUILD/u-boot-2016.01/drivers/mtd/spi/sf-uclass.c:61: undefined reference to `sprintf' /builddir/build/BUILD/u-boot-2016.01/scripts/Makefile.spl:244: recipe for target 'spl/u-boot-spl' failed make[2]: *** [spl/u-boot-spl] Error 1 /builddir/build/BUILD/u-boot-2016.01/Makefile:1330: recipe for target 'spl/u-boot-spl' failed make[1]: Leaving directory '/builddir/build/BUILD/u-boot-2016.01/builds/chromebook_jerry' make[1]: *** [spl/u-boot-spl] Error 2 Makefile:150: recipe for target 'sub-make' failed make: *** [sub-make] Error 2
[1] https://kojipkgs.fedoraproject.org//work/tasks/2458/12522458/build.log
participants (3)
-
Peng Fan
-
Peter Robinson
-
Tom Rini