[MacPorts] #62134: wget @1.21.1 does not build on PPC Leopard, Mac OS X 10.5.8, because of "error: 'for' loop initial declaration used outside C99 mode'"

MacPorts noreply at macports.org
Sat Jan 23 19:47:13 UTC 2021


#62134: wget @1.21.1 does not build on PPC Leopard, Mac OS X 10.5.8, because of
"error: 'for' loop initial declaration used outside C99 mode'"
-----------------------+--------------------
 Reporter:  ballapete  |      Owner:  (none)
     Type:  defect     |     Status:  new
 Priority:  Normal     |  Milestone:
Component:  ports      |    Version:  2.6.4
 Keywords:  leopard    |       Port:  wget
-----------------------+--------------------
 {{{
         /usr/bin/gcc-4.2 -DHAVE_CONFIG_H -I. -I../src
 -DDEFAULT_TEXT_DOMAIN=\"wget-gnulib\" -I/opt/local/include   -DNDEBUG
 -pipe -Os -arch ppc -MT tempname.o -MD -MP -MF $depbase.Tpo -c -o
 tempname.o tempname.c &&\
         mv -f $depbase.Tpo $depbase.Po
 tempname.c: In function 'random_bits':
 tempname.c:92: warning: integer constant is too large for 'long' type
 tempname.c:92: warning: this decimal constant is unsigned only in ISO C90
 tempname.c: In function 'try_tempname_len':
 tempname.c:290: error: 'for' loop initial declaration used outside C99
 mode
 make[3]: *** [tempname.o] Error 1
 make[3]: Leaving directory
 `/opt/local/var/macports/build/_opt_local_var_macports_sources_nue.de.rsync.macports.org_macports_release_tarballs_ports_net_wget/wget/work/wget-1.21.1/lib'
 make[2]: *** [all] Error 2
 }}}

 The function is this one:

 {{{
   233   #ifdef _LIBC
   234   static
   235   #endif
   236   int
   237   try_tempname_len (char *tmpl, int suffixlen, void *args,
   238                     int (*tryfunc) (char *, void *), size_t
 x_suffix_len)
   239   {
   240     size_t len;
   241     char *XXXXXX;
   242     unsigned int count;
   243     int fd = -1;
   244     int save_errno = errno;
   245
   246     /* A lower bound on the number of temporary files to attempt to
   247        generate.  The maximum total number of temporary file names
 that
   248        can exist for a given template is 62**6.  It should never be
   249        necessary to try all of these combinations.  Instead if a
 reasonable
   250        number of names is tried (we define reasonable as 62**3) fail
 to
   251        give the system administrator the chance to remove the
 problems.
   252        This value requires that X_SUFFIX_LEN be at least 3.  */
   253   #define ATTEMPTS_MIN (62 * 62 * 62)
   254
   255     /* The number of times to attempt to generate a temporary file.
 To
   256        conform to POSIX, this must be no smaller than TMP_MAX.  */
   257   #if ATTEMPTS_MIN < TMP_MAX
   258     unsigned int attempts = TMP_MAX;
   259   #else
   260     unsigned int attempts = ATTEMPTS_MIN;
   261   #endif
   262
   263     /* A random variable.  The initial value is used only the for
 fallback path
   264        on 'random_bits' on 'getrandom' failure.  Its initial value
 tries to use
   265        some entropy from the ASLR and ignore possible bits from the
 stack
   266        alignment.  */
   267     random_value v = ((uintptr_t) &v) / alignof (max_align_t);
   268
   269     /* How many random base-62 digits can currently be extracted
 from V.  */
   270     int vdigits = 0;
   271
   272     /* Least unfair value for V.  If V is less than this, V can
 generate
   273        BASE_62_DIGITS digits fairly.  Otherwise it might be biased.
 */
   274     random_value const unfair_min
   275       = RANDOM_VALUE_MAX - RANDOM_VALUE_MAX % BASE_62_POWER;
   276
   277     len = strlen (tmpl);
   278     if (len < x_suffix_len + suffixlen
   279         || strspn (&tmpl[len - x_suffix_len - suffixlen], "X") <
 x_suffix_len)
   280       {
   281         __set_errno (EINVAL);
   282         return -1;
   283       }
   284
   285     /* This is where the Xs start.  */
   286     XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
   287
   288     for (count = 0; count < attempts; ++count)
   289       {
   290         for (size_t i = 0; i < x_suffix_len; i++)
 <<<<<<<<<<<<<<<
   291           {
   292             if (vdigits == 0)
   293               {
   294                 do
   295                   v = random_bits (v);
   296                 while (unfair_min <= v);
   297
   298                 vdigits = BASE_62_DIGITS;
   299               }
   300
   301             XXXXXX[i] = letters[v % 62];
   302             v /= 62;
   303             vdigits--;
   304           }
   305
   306         fd = tryfunc (tmpl, args);
   307         if (fd >= 0)
   308           {
   309             __set_errno (save_errno);
   310             return fd;
   311           }
   312         else if (errno != EEXIST)
   313           return -1;
   314       }
   315
   316     /* We got out of the loop because we ran out of combinations to
 try.  */
   317     __set_errno (EEXIST);
   318     return -1;
   319   }
 }}}

 I presume it's that "`size_t i = 0;`" that causes the error.
 (`x_suffix_len` is an argument of this function.) So we have two options
 to solve: `GCC7` or declare both `len` and `i` at the beginning of the
 finction.

-- 
Ticket URL: <https://trac.macports.org/ticket/62134>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list