delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/06/14/02:08:18

Message-ID: <3947138A.B3F6979D@softhome.net>
Date: Wed, 14 Jun 2000 08:09:30 +0300
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.73 [en] (Win98; U)
X-Accept-Language: lt,en
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
Subject: Re: A fix for warning in dosexec.c
References: <3946A93A DOT 8805F454 AT softhome DOT net> <200006132330 DOT TAA23228 AT envy DOT delorie DOT com>
Reply-To: djgpp-workers AT delorie DOT com

DJ Delorie wrote:
> 
> > i is compared with sizeof(line) which is unsigned.
> >
> > OK to commit?
> 
> No, because later that same i is used to hold the return value of the
> function, which is a signed int.  How about creating a new unsigned
> variable `u' or something like that?

Like following?

Index: src/libc/dos/process/dosexec.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/dos/process/dosexec.c,v
retrieving revision 1.6
diff -u -r1.6 dosexec.c
--- dosexec.c	2000/05/31 17:53:46	1.6
+++ dosexec.c	2000/06/14 06:05:02
@@ -814,6 +814,7 @@
   FILE *f;
   char **newargs;
   int i, hasargs=0;
+  unsigned int ln;
   char *base, *p;
   int has_extension = 0, has_drive = 0;
   char pinterp[FILENAME_MAX];
@@ -832,8 +833,8 @@
     return go32_exec(program, argv, envp);
 
   /* Paranoia: is this at all a text file?  */
-  for (i=0; i < sizeof(line)-1 && line[i] != '\0'; i++)
-    if (line[i] < 7 && line[i] >= 0)
+  for (ln=0; ln < sizeof(line)-1 && line[ln] != '\0'; ln++)
+    if (line[ln] < 7 && line[ln] >= 0)
       return direct_exec(program, argv, envp);
 
   iargs[0] = 0;

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019