svn commit: r295812 - projects/mips64-clang/sys/mips/rmi

Ian Lepore ian at freebsd.org
Sun Feb 21 14:47:53 UTC 2016


On Fri, 2016-02-19 at 16:37 +0000, Sean Bruno wrote:
> Author: sbruno
> Date: Fri Feb 19 16:37:06 2016
> New Revision: 295812
> URL: https://svnweb.freebsd.org/changeset/base/295812
> 
> Log:
>   Change a static const string to a #define as the strcpy() throws a
>   warn/error with clang.
>   
>   /home/sbruno/mips64-clang/sys/mips/rmi/xls_ehci.c:133:25: error:
>   format string is not a string literal (potentially insecure)
>   	[-Werror,-Wformat-security]
>           sprintf(sc->sc_vendor, xlr_vendor_desc);
> 
> Modified:
>   projects/mips64-clang/sys/mips/rmi/xls_ehci.c
> 
> Modified: projects/mips64-clang/sys/mips/rmi/xls_ehci.c
> =====================================================================
> =========
> --- projects/mips64-clang/sys/mips/rmi/xls_ehci.c	Fri Feb 19
> 15:53:08 2016	(r295811)
> +++ projects/mips64-clang/sys/mips/rmi/xls_ehci.c	Fri Feb 19
> 16:37:06 2016	(r295812)
> @@ -73,7 +73,7 @@ static device_attach_t ehci_xls_attach;
>  static device_detach_t ehci_xls_detach;
>  
>  static const char *xlr_usb_dev_desc = "RMI XLR USB 2.0 controller";
> -static const char *xlr_vendor_desc = "RMI Corp";
> +#define XLR_VENDOR_DESC "RMI Corp";
>  
>  static int
>  ehci_xls_probe(device_t self)
> @@ -130,7 +130,7 @@ ehci_xls_attach(device_t self)
>  	device_set_ivars(sc->sc_bus.bdev, &sc->sc_bus);
>  	device_set_desc(sc->sc_bus.bdev, xlr_usb_dev_desc);
>  
> -	sprintf(sc->sc_vendor, xlr_vendor_desc);
> +	sprintf(sc->sc_vendor, XLR_VENDOR_DESC);
>  
>  	err = bus_setup_intr(self, sc->sc_irq_res,
>  	    INTR_TYPE_BIO | INTR_MPSAFE, NULL,
> 

Bah.  The compiler should understand that a static const char* is
equivelent to a string literal for the purposes of this warning.

That said, a sprintf() is just a strange spelling of strlcpy() here.

-- Ian



More information about the svn-src-projects mailing list