[dpdk-dev] [PATCH 5/5] Fix usage of fgets in various places

Panu Matilainen pmatilai at redhat.com
Tue Feb 24 10:20:33 CET 2015


On 02/23/2015 06:00 PM, Stephen Hemminger wrote:
> On Mon, 23 Feb 2015 15:10:00 +0100
> Pawel Wodkowski <pawelx.wodkowski at intel.com> wrote:
>
>> Declaration of fgets() is
>> char *fgets(char *str, int size, FILE *stream);
>>
>> Klocwork complain about passing "sizeof()" as size parameter since
>> implicit casting size_t to int might cause loss of precision.
>>
>> Signed-off-by: Pawel Wodkowski <pawelx.wodkowski at intel.com>
>
> NAK this is shooting at Unicorns.
> The tool is the problem not the code.

The tool is technically correct, even if loss of precision might be 
unlikely to occur in this context.

However the patch is incorrect, the problem doesn't go away by adding an 
explict cast even if it shuts up the tool.

	- Panu -



More information about the dev mailing list