paxutils-forum
[Top][All Lists]
Advanced

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

GNU tar 1.13.19: compilation warning in create.c: mode_to_chars()


From: Jonathan Thornburg
Subject: GNU tar 1.13.19: compilation warning in create.c: mode_to_chars()
Date: Mon, 5 Mar 2001 18:05:13 +0100

When compiling 1.13.19 on an i386-unknown-openbsd2.8 system, gcc
gives a warning message 

  create.c: In function `mode_to_chars':
  create.c:262: warning: comparison is always false due to limited range of 
data type

The code in question (src/create.c) is this:

  void
  mode_to_chars (mode_t v, char *p, size_t s)
  {
    /* In the common case where the internal and external mode bits are the 
same,
       and we are not using POSIX or GNU format,
       propagate all unknown bits to the external mode.
       This matches historical practice.
       Otherwise, just copy the bits we know about.  */
    int negative;
    uintmax_t u;
    if (S_ISUID == TSUID && S_ISGID == TSGID && S_ISVTX == TSVTX
        && S_IRUSR == TUREAD && S_IWUSR == TUWRITE && S_IXUSR == TUEXEC
        && S_IRGRP == TGREAD && S_IWGRP == TGWRITE && S_IXGRP == TGEXEC
        && S_IROTH == TOREAD && S_IWOTH == TOWRITE && S_IXOTH == TOEXEC
        && archive_format != POSIX_FORMAT
        && archive_format != GNU_FORMAT)
      {
        negative = v < 0;

where the warning is reported on the last line (mode_t is u_int16_t
on this system).  Is this a genuine bug, or is there deep magic here
related to the C type-promotion rules?  I _think_ it's safe to ignore
the warning here, but I'm not at all sure...

-- 
-- Jonathan Thornburg <address@hidden>
   http://www.thp.univie.ac.at/~jthorn/home.html
   Universitaet Wien (Vienna, Austria) / Institut fuer Theoretische Physik
   "C++ is to programming as sex is to reproduction. Better ways might
    technically exist but they're not nearly as much fun." -- Nikolai Irgens



reply via email to

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