[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stat signed/unsigned

From: Jim Meyering
Subject: Re: stat signed/unsigned
Date: Fri, 16 Jan 2009 11:30:53 +0100

Pádraig Brady <address@hidden> wrote:
> I've split up my "avoid -Wsign-compare warnings" patch,
> like Jim originally requested.
> Attached are IMHO the non contentious patches.
> The rest which I'll drop for the moment all boil
> down to passing unsigned ints as field widths to
> printf, and treating stat.st_size as unsigned.

Hi Pádraig!

>>From c91df53022c168f84f70364465f58e434794b172 Mon Sep 17 00:00:00 2001
> From: =?utf-8?q?P=C3=A1draig=20Brady?= <address@hidden>
> Date: Wed, 14 Jan 2009 19:17:39 +0000
> Subject: [PATCH] simplify mgetgroups() and avoid -Wsign-compare warnings
> * gl/lib/mgetgroups.c: Don't explicitly call memcpy() or malloc()
> and also avoid -Wsign-compare warning by using appropriate
> types for the parameters of realloc_groupbuf().

The changes to the two files below are fine.

> * src/group-list.c: Use int rather than size_t as variable is
> used in signed comparisons.
> * src/id.c: ditto.

But while the mgetgroups.c changes seem fine,
they deserve a longer note in the log.  And it should
mention that this is not just about warning-avoidance.

A minor disadvantage is that with your change, mgetgroups
always calls realloc_groupbuf twice, whereas before, it'd
usually perform only one malloc call.  That micro-pessimization
is probably outweighed by your code-size reduction.

Also, please humor me and undo this change:
> -       if (0 <= ng)
> +       if (ng >= 0)

So, it's ok to commit that separately, but with a more detailed log.

I notice that your shred change does something similar,
but don't mind if you leave that one as-is.
The rest are fine, too.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]