coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] maint: remove useless (off_t) cast of lseek arg


From: Jim Meyering
Subject: Re: [PATCH] maint: remove useless (off_t) cast of lseek arg
Date: Sat, 28 May 2011 23:47:10 +0200

Jim Meyering wrote:

> These (off_t) casts are anachronistic.
> They were useful in pre-ANSI-C days, i.e., before prototypes.
> There are two remaining off_t casts, and neither appears useful:
> (one is even inconsistently formatted, with no space after the ")" ;-)
>
>   src/shred.c:      if (offset > OFF_T_MAX - (off_t) soff)
>   src/truncate.c:          if (ssize > OFF_T_MAX - (off_t)fsize)
>
> So I'll probably remove them, too.

Now I'm not so sure.
soff is of type size_t and fsize is uintmax_t,
each of which may be wider than off_t.
I suspect that each of these trigger one of the warnings
that we have not enabled.

>From dbf620292d6bcae2294da671172fb5629a9855c9 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Sat, 28 May 2011 23:40:42 +0200
Subject: [PATCH] maint: remove useless (off_t) casts

* src/truncate.c (do_ftruncate): Remove cast.
* src/shred.c (dopass): Likewise.
---
 src/shred.c    |    2 +-
 src/truncate.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/shred.c b/src/shred.c
index ecb27b8..13d1b16 100644
--- a/src/shred.c
+++ b/src/shred.c
@@ -488,7 +488,7 @@ dopass (int fd, char const *qname, off_t *sizep, int type,

       /* Okay, we have written "soff" bytes. */

-      if (offset > OFF_T_MAX - (off_t) soff)
+      if (offset > OFF_T_MAX - soff)
         {
           error (0, 0, _("%s: file too large"), qname);
           return -1;
diff --git a/src/truncate.c b/src/truncate.c
index 30097ac..d542f3e 100644
--- a/src/truncate.c
+++ b/src/truncate.c
@@ -199,7 +199,7 @@ do_ftruncate (int fd, char const *fname, off_t ssize, off_t 
rsize,
         }
       else
         {
-          if (ssize > OFF_T_MAX - (off_t)fsize)
+          if (ssize > OFF_T_MAX - fsize)
             {
               error (0, 0, _("overflow extending size of file %s"),
                      quote (fname));
--
1.7.5.2.660.g9f46c



reply via email to

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