Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Feb 2013 07:07:15 -0800
From:      Patrick Powell <papowell@astart.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Eliminating a warning in sys/boot
Message-ID:  <51190923.7090907@astart.com>
In-Reply-To: <CALCpEUFL1YfAY=S8XOAXSowZfiRGipv=OC_hj060VE348ozUzg@mail.gmail.com>
References:  <1360455011.4618.8.camel@powernoodle> <CALCpEUFL1YfAY=S8XOAXSowZfiRGipv=OC_hj060VE348ozUzg@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 02/10/13 01:27, hiren panchasara wrote:
> On Sat, Feb 9, 2013 at 4:10 PM, Sean Bruno <seanwbruno@gmail.com> wrote:
>> So, this is not a valid warning in our universe and I'd like to silence
>> it when compiling sys/boot as printf(9) and sprintf(9) supports this
>> format.  How can we silence this warning for the FreeBSD universe?
>>
>> ===> efi/libefi (all)
>> In file included from efinet.c:39:
>> /home/sbruno/fbsd_head/sys/boot/efi/libefi/../../common/dev_net.c:328:19: warning: invalid conversion specifier 'D'
>>        [-Wformat-invalid-specifier]
>>          sprintf(temp, "%6D", d->myea, ":");
> Here "d->myea" being char pointer, can we not do following instead? :
> sprintf(temp, "%6s", d->myea, ":");


NO NO NO NO!   I really suggest that sprintf be removed from the C library.

Try:
char fixed_buffer[32];
snprintf(fixed_buffer, sizeof(fixed_buffer), "%6whateverformat",whatever);


-- 
Patrick Powell                 Astart Technologies
papowell@astart.com            1530 Jamacha Road, Suite X,
Network and System             El Cajon, CA 92019
   Consulting                   858-874-6543
Web Site: www.astart.com




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51190923.7090907>