This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Change maxsize_* and last_* from size_t to uint64_t in memusagestat.c


On Fri, Oct 30, 2009 at 9:45 AM, Holger Freyther <zecke@selfish.org> wrote:
> 2009-10-30 ?Holger Hans Peter Freyther <zecke@selfish.org>
>
> ? ? ? ?* malloc/memusagestat.c (main): Change the type from size_t to uint64_t
> ? ? ? ?in maxsize_heap, maxsize_stack, maxsize_total, last_heap, last_stack,
> ? ? ? ?last_total to avoid assigning from an unsigned to a signed type.

Same problem as before with your ChangeLog.

The comment is also incorrect. The type size_t is by definition
unsigned, therefore there should be no assignment from a signed to
unsigned type.

What is the actual error message you were seeing?

> ---
> ?malloc/memusagestat.c | ? 12 ++++++------
> ?1 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/malloc/memusagestat.c b/malloc/memusagestat.c
> index a5a3150..d8b638d 100644
> --- a/malloc/memusagestat.c
> +++ b/malloc/memusagestat.c
> @@ -122,16 +122,16 @@ main (int argc, char *argv[])
> ? int grey, blue, red, green, yellow, black;
> ? int fd;
> ? struct stat st;
> - ?size_t maxsize_heap;
> - ?size_t maxsize_stack;
> - ?size_t maxsize_total;
> + ?uint64_t maxsize_heap;
> + ?uint64_t maxsize_stack;
> + ?uint64_t maxsize_total;
> ? uint64_t total;
> ? uint64_t cnt, cnt2;
> ? FILE *outfile;
> ? char buf[30];
> - ?size_t last_heap;
> - ?size_t last_stack;
> - ?size_t last_total;
> + ?uint64_t last_heap;
> + ?uint64_t last_stack;
> + ?uint64_t last_total;
> ? struct entry headent[2];
> ? uint64_t start_time;
> ? uint64_t end_time;
> --
> 1.6.3.3

Because the struct entry has uint64_t values, these should also be
uint64_t values to match.

It has nothing to do with being signed or unsigned, but size_t might
be uint32_t, while struct entry might be uint64_t and assignment may
overflow.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]