bug-coreutils
[Top][All Lists]
Advanced

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

Re: truncate.c fails to compile on make distcheck


From: Jim Meyering
Subject: Re: truncate.c fails to compile on make distcheck
Date: Thu, 26 Jun 2008 11:13:15 +0200

Pádraig Brady <address@hidden> wrote:
> Jim Meyering wrote:
>> Pádraig Brady <address@hidden> wrote:
>>> Jim Meyering wrote:
>>>> Here's a tentative patch:
>> ...
>>> I reviewed all uses of off_t in the code and came up with
>>> an almost identical patch, so I'm happy to go with the above.
>> 
>> Hi Pádraig,
>> Thanks for checking.
>> Here's what I've pushed:
>> [I added the IF_LINT initializer]
>
> Hmm, it's probably cleaner to assign *size unconditionally,
> as I had done in my patch, but it doesn't really matter.

But this statement

  > +  *size = tmp_size;

would set *size to an uninitialized value upon failure.
It's just that gcc doesn't detect it (yet).

> I also noticed this morning that some format specifiers also
> assumed sizeof(off_t) == sizeof(intmax_t) and thus would
> print garbage off the stack if this wasn't the case.
...

By the way, does %zu work reliably everywhere now?
In the past, we've converted such values to strings via umaxtostr,
to accommodate older systems.

For ssize and nsize, I have a slight preference for the
cast-free approach of using %s with imaxtostr.

Do you feel like making those changes?

> @@ -148,7 +152,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, 
> rel_mode_t rel_mode)
>          {
>            error (0, 0,
>                   _("overflow in %" PRIdMAX
> -                   " * %zu byte blocks for file %s"), ssize, blksize,
> +                   " * %zu byte blocks for file %s"), (intmax_t) ssize, 
> blksize,
>                   quote (fname));
>            return 1;
>          }
> @@ -229,7 +233,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, 
> rel_mode_t rel_mode)
>          {
>            error (0, ftruncate_errno,
>                   _("truncating %s at %" PRIdMAX " bytes"), quote (fname),
> -                 nsize);
> +                 (intmax_t) nsize);
>            return 1;
>          }
>        return 0;




reply via email to

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