Mail Archives: djgpp-workers/1997/10/23/03:54:22
This is a multi-part message in MIME format.
--------------754C11F2220E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I've got again a few patches, that avoid the compiler to generate
warnings when signed and unsigned values are compared. I only solved the
problems that I didn't have to create myself. To modify other int's,
I'll wait until after the next alpha release because else too many
patches will accumulate and it will be very hard to combine by the
maintainer.
If you don't know where I'm talking about you may want to read the
message "libc & -Wsign-compare" posted on Wed, 22 Oct 1997 11:53:29
+0200 to djgpp-workers@
What I actually did was either:
- changing the variable's type from int to unsigned, when I was sure
that the variable couldn't receive a negative value.
- when I was not absolutely sure, I put a cast in front of the variable
if I knew that its current contents were positive.
- else I changed the comparison as explained in the message referred to
above and optimized it if I could.
- on a rare occasion a changed an unsigned to an int, because the var
got assigned from a function returning int.
Applying the patch:
Make sure you have installed all include/* and all src/* files in the
$(DJDIR) directory or whatever directory you want to make the changes
in.
I assume you have applied any of my previous patches:
src00_01.dif src01_02.dif src02_03.dif
Change to the $(DJDIR) directory
Then apply the patch:
patch -p1 < fname
You shouldn't get any rejects, as I test all my patches before
distributing.
PS. All of my patches so far to the 971009 alpha release are available
on the net at URL
http://studwww.rug.ac.be/~vheyndri/djgpp-patches/index.html
That's all folks.
--
+----------------+
| Vik Heyndrickx |
+----------------+
--------------754C11F2220E
Content-Type: text/plain; charset=us-ascii; name="src03_04.dif"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="src03_04.dif"
diff -u -r -N 03/src/libc/ansi/locale/mbstowcs.c 04/src/libc/ansi/locale/mbstowcs.c
--- 03/src/libc/ansi/locale/mbstowcs.c Tue Nov 29 11:18:20 1994
+++ 04/src/libc/ansi/locale/mbstowcs.c Wed Oct 22 21:25:58 1997
@@ -4,8 +4,8 @@
size_t
mbstowcs(wchar_t *wcs, const char *s, size_t n)
{
- int i;
- for (i=0; s[i] && (i<n-1); i++)
+ size_t i;
+ for (i=0; s[i] && i+1 < n; i++)
wcs[i] = s[i];
wcs[i] = 0;
return i;
diff -u -r -N 03/src/libc/ansi/locale/wcstombs.c 04/src/libc/ansi/locale/wcstombs.c
--- 03/src/libc/ansi/locale/wcstombs.c Tue Nov 29 11:18:12 1994
+++ 04/src/libc/ansi/locale/wcstombs.c Wed Oct 22 21:25:58 1997
@@ -4,8 +4,8 @@
size_t
wcstombs(char *s, const wchar_t *wcs, size_t n)
{
- int i;
- for (i=0; wcs[i] && (i<n-1); i++)
+ size_t i;
+ for (i=0; wcs[i] && i+1 < n; i++)
s[i] = wcs[i];
s[i] = 0;
return i;
diff -u -r -N 03/src/libc/ansi/stdio/doscan.c 04/src/libc/ansi/stdio/doscan.c
--- 03/src/libc/ansi/stdio/doscan.c Wed Oct 22 19:43:28 1997
+++ 04/src/libc/ansi/stdio/doscan.c Wed Oct 22 21:25:58 1997
@@ -353,17 +353,18 @@
_getccl(const unsigned char *s)
{
register int c, t;
+ unsigned i;
t = 0;
if (*s == '^') {
t++;
s++;
}
- for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++)
+ for (i = 0; i < (sizeof _sctab / sizeof _sctab[0]); i++)
if (t)
- _sctab[c] &= ~STP;
+ _sctab[i] &= ~STP;
else
- _sctab[c] |= STP;
+ _sctab[i] |= STP;
if ((c = *s) == ']' || c == '-') { /* first char is special */
if (t)
_sctab[c] |= STP;
diff -u -r -N 03/src/libc/ansi/stdio/fread.c 04/src/libc/ansi/stdio/fread.c
--- 03/src/libc/ansi/stdio/fread.c Wed Oct 22 19:43:52 1997
+++ 04/src/libc/ansi/stdio/fread.c Wed Oct 22 21:25:58 1997
@@ -14,7 +14,7 @@
/* grow if we know we're asking for a lot, even if it's in the
buffer, since we'll probably read chunks this size for a while */
- while (size*count > iop->_fillsize
+ while (size*count > (size_t)iop->_fillsize
&& iop->_fillsize < iop->_bufsiz)
{
if (iop->_fillsize < 512)
diff -u -r -N 03/src/libc/ansi/stdlib/malloc.c 04/src/libc/ansi/stdlib/malloc.c
--- 03/src/libc/ansi/stdlib/malloc.c Mon Dec 26 22:35:02 1994
+++ 04/src/libc/ansi/stdlib/malloc.c Wed Oct 22 21:25:58 1997
@@ -80,7 +80,7 @@
#define NBUCKETS 30
static union overhead *nextf[NBUCKETS];
-static int pagesz; /* page size */
+static unsigned pagesz; /* page size */
static int pagebucket; /* page size bucket */
#ifdef MSTATS
@@ -141,7 +141,7 @@
* stored in hash buckets which satisfies request.
* Account for space used per block for accounting.
*/
- if (nbytes <= (n = pagesz - sizeof (*op) - RSLOP)) {
+ if (nbytes <= (size_t)(n = pagesz - (sizeof (*op) + RSLOP))) {
#ifndef RCHECK
amt = 8; /* size of first bucket */
bucket = 0;
@@ -195,7 +195,7 @@
morecore(int bucket)
{
union overhead *op;
- int sz; /* size of desired block */
+ unsigned sz; /* size of desired block */
int amt; /* amount to allocate */
int nblks; /* how many blocks we get */
@@ -265,7 +265,7 @@
realloc(void *cp, size_t nbytes)
{
unsigned int onb;
- int i;
+ unsigned i;
union overhead *op;
char *res;
int was_alloced = 0;
@@ -291,10 +291,9 @@
if (was_alloced) {
if (i) {
i = 1 << (i + 2);
- if (i < pagesz)
- i -= sizeof (*op) + RSLOP;
- else
- i += pagesz - sizeof (*op) - RSLOP;
+ if (i >= pagesz)
+ i += pagesz;
+ i -= sizeof (*op) + RSLOP;
}
if (nbytes <= onb && nbytes > i) {
#ifdef RCHECK
diff -u -r -N 03/src/libc/ansi/time/ctime.c 04/src/libc/ansi/time/ctime.c
--- 03/src/libc/ansi/time/ctime.c Sun Aug 31 20:52:58 1997
+++ 04/src/libc/ansi/time/ctime.c Wed Oct 22 21:25:58 1997
@@ -310,7 +310,7 @@
else
{
i = read(fid, buf, sizeof buf);
- if (close(fid) != 0 || i < sizeof *tzhp)
+ if (close(fid) != 0 || i == -1 || (unsigned)i < sizeof *tzhp)
return -1;
}
@@ -326,7 +326,7 @@
sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
(ttisstdcnt != sp->typecnt && ttisstdcnt != 0))
return -1;
- if (i < sizeof *tzhp +
+ if ((unsigned)i < sizeof *tzhp +
sp->timecnt * (4 + sizeof (char)) +
sp->typecnt * (4 + 2 * sizeof (char)) +
sp->charcnt * sizeof (char) +
@@ -677,7 +677,7 @@
{
const char * stdname;
const char * dstname=0;
- int stdlen;
+ unsigned stdlen;
int dstlen;
long stdoffset;
long dstoffset;
@@ -882,7 +882,7 @@
sp->charcnt = stdlen + 1;
if (dstlen != 0)
sp->charcnt += dstlen + 1;
- if (sp->charcnt > sizeof sp->chars)
+ if ((unsigned)sp->charcnt > sizeof sp->chars)
return -1;
cp = sp->chars;
(void) strncpy(cp, stdname, stdlen);
diff -u -r -N 03/src/libc/bios/biosdisk.c 04/src/libc/bios/biosdisk.c
--- 03/src/libc/bios/biosdisk.c Mon Oct 9 08:00:00 1995
+++ 04/src/libc/bios/biosdisk.c Wed Oct 22 21:25:58 1997
@@ -45,7 +45,8 @@
biosdisk(int cmd, int drive, int head, int track,
int sector, int nsects, void *buffer)
{
- int seg=0, ofs=0, xfer=0, before=0;
+ int seg=0, ofs=0, before=0;
+ unsigned xfer = 0;
__dpmi_regs r;
switch (cmd)
{
@@ -120,7 +121,8 @@
unsigned
_bios_disk(unsigned _cmd, struct diskinfo_t *_di)
{
- int seg=0, ofs=0, xfer=0, before=0;
+ int seg=0, ofs=0, before=0;
+ unsigned xfer = 0;
__dpmi_regs r;
switch( _cmd )
diff -u -r -N 03/src/libc/compat/ioctl/ioctl.c 04/src/libc/compat/ioctl/ioctl.c
--- 03/src/libc/compat/ioctl/ioctl.c Sun Sep 1 19:46:06 1996
+++ 04/src/libc/compat/ioctl/ioctl.c Wed Oct 22 21:25:58 1997
@@ -152,7 +152,7 @@
** I _do_ like clear APIs.
*/
if(cmd & DOS_XFER){
- if(argcx <= __tb_size){ /* Can we use transfer buffer ? */
+ if((size_t)argcx <= __tb_size){ /* Can we use transfer buffer ? */
dosmemput((void *)argdx,argcx, __tb);
r.x.ds = (__tb>>4) &0xffff;
r.x.dx = __tb &0xf;
@@ -178,7 +178,7 @@
** parameter after all the registers and the buffer pointer.
*/
if( cmd & DOS_BRAINDEAD ){
- if(xarg <= __tb_size){ /* Can we use transfer buffer ? */
+ if((size_t)xarg <= __tb_size){ /* Can we use transfer buffer ? */
dosmemput((void *)argdx,xarg, __tb);
r.x.ds = (__tb>>4) &0xffff;
r.x.dx = __tb &0xf;
diff -u -r -N 03/src/libc/compat/mman/mprotect.c 04/src/libc/compat/mman/mprotect.c
--- 03/src/libc/compat/mman/mprotect.c Fri Dec 15 18:42:40 1995
+++ 04/src/libc/compat/mman/mprotect.c Wed Oct 22 21:25:58 1997
@@ -25,7 +25,7 @@
{
unsigned short pageprot[npage];
- int i;
+ unsigned i;
__dpmi_meminfo meminfo;
__djgpp_sbrk_handle *handle_info;
diff -u -r -N 03/src/libc/compat/mntent/mntent.c 04/src/libc/compat/mntent/mntent.c
--- 03/src/libc/compat/mntent/mntent.c Tue Aug 13 05:14:46 1996
+++ 04/src/libc/compat/mntent/mntent.c Wed Oct 22 21:25:58 1997
@@ -207,7 +207,7 @@
illegal address abort when we try to peek at the signature below.
Actually, it's enough to test for (FFFFFh - 55h - drive), because
we need to get the host drive number at that offset. */
- if (stac_driver_ptr > 0x0000fffaa - drive_num)
+ if (stac_driver_ptr + drive_num > 0x0000fffaa)
return 0;
/* Stacker Anywhere returns pointer to 1 byte before the A55Ah
diff -u -r -N 03/src/libc/crt0/mcount.c 04/src/libc/crt0/mcount.c
--- 03/src/libc/crt0/mcount.c Wed Oct 22 19:43:58 1997
+++ 04/src/libc/crt0/mcount.c Wed Oct 22 21:25:58 1997
@@ -49,9 +49,9 @@
{
MTAB *m;
int i;
- int to;
- int ebp;
- int from;
+ long unsigned to;
+ long unsigned ebp;
+ long unsigned from;
int mtabi;
MTABE **cache;
diff -u -r -N 03/src/libc/dos/compat/d_read.c 04/src/libc/dos/compat/d_read.c
--- 03/src/libc/dos/compat/d_read.c Mon Oct 9 08:00:00 1995
+++ 04/src/libc/dos/compat/d_read.c Wed Oct 22 21:25:58 1997
@@ -24,7 +24,8 @@
/* Allocate ~64K or less transfer buffer from DOS */
dos_buffer_size = ( count < 0xFFE0 ) ? count : 0xFFE0;
- if ( (dos_segment=__dpmi_allocate_dos_memory((dos_buffer_size + 15) >> 4, &dos_selector)) == -1 )
+ dos_segment = __dpmi_allocate_dos_memory((dos_buffer_size + 15) >> 4, &dos_selector);
+ if ((int)dos_segment == -1)
{
errno = ENOMEM;
return 8;
diff -u -r -N 03/src/libc/dos/compat/d_write.c 04/src/libc/dos/compat/d_write.c
--- 03/src/libc/dos/compat/d_write.c Mon Oct 9 08:00:00 1995
+++ 04/src/libc/dos/compat/d_write.c Wed Oct 22 21:25:58 1997
@@ -24,7 +24,8 @@
/* Allocates ~64K or less transfer buffer from DOS */
dos_buffer_size = ( count < 0xFFE0 ) ? count : 0xFFE0;
- if ( (dos_segment=__dpmi_allocate_dos_memory((dos_buffer_size + 15) >> 4, &dos_selector)) == -1 )
+ dos_segment = __dpmi_allocate_dos_memory((dos_buffer_size + 15) >> 4, &dos_selector);
+ if ((int)dos_segment == -1)
{
errno = ENOMEM;
return 8;
diff -u -r -N 03/src/libc/dos/dir/srchpath.c 04/src/libc/dos/dir/srchpath.c
--- 03/src/libc/dos/dir/srchpath.c Sun Sep 1 03:09:32 1996
+++ 04/src/libc/dos/dir/srchpath.c Wed Oct 22 21:25:58 1997
@@ -12,7 +12,7 @@
#include <libc/environ.h>
#include <libc/bss.h>
-static int env_changed = 0;
+static unsigned env_changed = 0;
static int srchpath_bss_count = -1;
/* Search PATH for FILE.
diff -u -r -N 03/src/libc/dos/errno/doserr2e.c 04/src/libc/dos/errno/doserr2e.c
--- 03/src/libc/dos/errno/doserr2e.c Wed Aug 23 09:55:54 1995
+++ 04/src/libc/dos/errno/doserr2e.c Wed Oct 22 21:25:58 1997
@@ -20,9 +20,9 @@
};
int
-__doserr_to_errno(int doserr)
+__doserr_to_errno (int doserr)
{
- if (doserr >= 0 && doserr < sizeof(map)/sizeof(map[0]))
+ if (doserr >= 0 && (unsigned)doserr < sizeof(map)/sizeof(map[0]))
return map[doserr];
return EINVAL;
}
diff -u -r -N 03/src/libc/dos/io/dosio.c 04/src/libc/dos/io/dosio.c
--- 03/src/libc/dos/io/dosio.c Sat Nov 25 04:06:10 1995
+++ 04/src/libc/dos/io/dosio.c Wed Oct 22 21:25:58 1997
@@ -21,7 +21,7 @@
char *__file_handle_modes = init_file_handle_modes;
void
-__file_handle_set(int fd, int mode)
+__file_handle_set (int fd, int mode)
{
__dpmi_regs r;
@@ -38,7 +38,7 @@
/* See if we need to expand the tables. Check this BEFORE it might fail,
so that when we hit the count'th request, we've already up'd it. */
- if (fd >= (count-1) && count < 255)
+ if ((unsigned)fd+1 >= count && count < 255)
{
int oldcount = count;
count = 255;
diff -u -r -N 03/src/libc/dos/io/putpath.c 04/src/libc/dos/io/putpath.c
--- 03/src/libc/dos/io/putpath.c Sun Aug 31 19:09:02 1997
+++ 04/src/libc/dos/io/putpath.c Wed Oct 22 21:25:58 1997
@@ -16,7 +16,8 @@
void
_put_path2(const char *path, int offset)
{
- int o, space = _go32_info_block.size_of_transfer_buffer - offset;
+ int space = _go32_info_block.size_of_transfer_buffer - offset;
+ unsigned o;
const char *p = path;
if (path == 0)
diff -u -r -N 03/src/libc/dos/lfn/_use_lfn.c 04/src/libc/dos/lfn/_use_lfn.c
--- 03/src/libc/dos/lfn/_use_lfn.c Wed Oct 22 19:43:52 1997
+++ 04/src/libc/dos/lfn/_use_lfn.c Wed Oct 22 21:25:58 1997
@@ -144,7 +144,7 @@
unsigned drv_no;
_dos_getdrive(&drv_no);
- if (drv_no - 1 + 'A' != last_drive)
+ if ('A' + (int)(drv_no - 1) != last_drive)
same_drive_as_last_time = 0;
}
}
diff -u -r -N 03/src/libc/dos/process/chkv2prg.c 04/src/libc/dos/process/chkv2prg.c
--- 03/src/libc/dos/process/chkv2prg.c Fri Oct 10 03:40:02 1997
+++ 04/src/libc/dos/process/chkv2prg.c Wed Oct 22 21:25:58 1997
@@ -63,7 +63,7 @@
if (header[1])
coff_start += (long)header[1] - 512L;
exe_start = (unsigned long)header[4]*16L;
- if (lseek(pf, exe_start, SEEK_SET) != exe_start)
+ if ((long unsigned)lseek(pf, exe_start, SEEK_SET) != exe_start)
return &type;
if (read(pf, go32stub, 8) != 8)
return &type;
@@ -81,7 +81,7 @@
int struct_length;
unsigned short coff_id;
type.version.v.major = 1;
- if (lseek(pf, coff_start - 4, SEEK_SET) != coff_start-4)
+ if ((long unsigned)lseek(pf, coff_start - 4, SEEK_SET) != coff_start-4)
return &type;
if (read(pf, &stub_offset, 4) != 4)
return &type;
diff -u -r -N 03/src/libc/dos/process/dosexec.c 04/src/libc/dos/process/dosexec.c
--- 03/src/libc/dos/process/dosexec.c Fri Oct 10 03:37:06 1997
+++ 04/src/libc/dos/process/dosexec.c Wed Oct 22 21:25:58 1997
@@ -799,7 +799,8 @@
char line[130], interp[FILENAME_MAX], iargs[130];
FILE *f;
char **newargs;
- int i, hasargs=0;
+ int j, hasargs=0;
+ unsigned i;
char *base, *p;
int has_extension = 0, has_drive = 0;
char pinterp[FILENAME_MAX];
@@ -871,8 +872,8 @@
else
return -1;
- i = (*spawnfunc)(P_WAIT, pinterp, newargs, envp);
- return i;
+ j = (*spawnfunc)(P_WAIT, pinterp, newargs, envp);
+ return j;
}
/* Note: the following list is not supposed to mention *every*
diff -u -r -N 03/src/libc/go32/dpmiexcp.c 04/src/libc/go32/dpmiexcp.c
--- 03/src/libc/go32/dpmiexcp.c Wed Oct 22 19:43:52 1997
+++ 04/src/libc/go32/dpmiexcp.c Wed Oct 22 21:25:58 1997
@@ -319,7 +319,7 @@
__djgpp_exception_toggle(void)
{
__dpmi_paddr except;
- int i;
+ unsigned i;
for(i=0; i < EXCEPTION_COUNT; i++)
{
@@ -351,7 +351,7 @@
{
__dpmi_paddr except;
__dpmi_meminfo lockmem;
- int i;
+ unsigned i;
for (i = 0; i < SIGMAX; i++)
signal_list[i] = (SignalHandler)SIG_DFL;
diff -u -r -N 03/src/libc/posix/glob/globfree.c 04/src/libc/posix/glob/globfree.c
--- 03/src/libc/posix/glob/globfree.c Mon Mar 27 14:01:12 1995
+++ 04/src/libc/posix/glob/globfree.c Wed Oct 22 21:25:58 1997
@@ -4,7 +4,7 @@
void globfree(glob_t *_pglob)
{
- int i;
+ unsigned i;
if (!_pglob->gl_pathv)
return;
for (i=0; i<_pglob->gl_pathc; i++)
diff -u -r -N 03/src/libc/posix/sys/stat/chmod.c 04/src/libc/posix/sys/stat/chmod.c
--- 03/src/libc/posix/sys/stat/chmod.c Mon Aug 28 05:42:36 1995
+++ 04/src/libc/posix/sys/stat/chmod.c Wed Oct 22 21:25:58 1997
@@ -7,7 +7,7 @@
chmod(const char *filename, int pmode)
{
int dmode;
- unsigned attr = _chmod(filename, 0, 0);
+ int attr = _chmod(filename, 0, 0);
if (attr == -1)
return -1;
diff -u -r -N 03/src/libc/posix/sys/stat/is_exec.c 04/src/libc/posix/sys/stat/is_exec.c
--- 03/src/libc/posix/sys/stat/is_exec.c Sat Oct 19 17:24:46 1996
+++ 04/src/libc/posix/sys/stat/is_exec.c Wed Oct 22 21:25:58 1997
@@ -181,7 +181,7 @@
if ((_djstat_flags & _STAT_EXEC_EXT) == 0
&& extension
&& *extension
- && strlen(extension) <= ((extension[0]=='.') ? 4 : 3))
+ && strlen(extension) <= (size_t)((extension[0]=='.') ? 4 : 3))
{
/* Search the list of extensions in executables[]. */
char tmp_buf[6], *tp = tmp_buf;
diff -u -r -N 03/src/libc/posix/unistd/access.c 04/src/libc/posix/unistd/access.c
--- 03/src/libc/posix/unistd/access.c Mon Sep 8 02:10:40 1997
+++ 04/src/libc/posix/unistd/access.c Wed Oct 22 21:25:58 1997
@@ -10,7 +10,7 @@
int access(const char *fn, int flags)
{
- unsigned attr = _chmod(fn, 0);
+ int attr = _chmod(fn, 0);
if (attr == -1) {
struct ffblk ff;
diff -u -r -N 03/src/libc/posix/unistd/getcwd.c 04/src/libc/posix/unistd/getcwd.c
--- 03/src/libc/posix/unistd/getcwd.c Sun Sep 1 03:09:32 1996
+++ 04/src/libc/posix/unistd/getcwd.c Wed Oct 22 21:25:58 1997
@@ -18,7 +18,8 @@
{
char *bp;
__dpmi_regs r;
- int needed_length, c;
+ unsigned needed_length;
+ int c;
unsigned use_lfn = _USE_LFN;
int preserve_case = _preserve_fncase();
char *name_start;
diff -u -r -N 03/src/libc/posix/unistd/sleep.c 04/src/libc/posix/unistd/sleep.c
--- 03/src/libc/posix/unistd/sleep.c Sun Mar 12 23:28:52 1995
+++ 04/src/libc/posix/unistd/sleep.c Wed Oct 22 21:25:58 1997
@@ -7,7 +7,7 @@
sleep(unsigned int _seconds)
{
clock_t start_time = clock();
- while (clock()-start_time < _seconds * CLOCKS_PER_SEC)
+ while ((long unsigned)(clock()-start_time) < _seconds * CLOCKS_PER_SEC)
__dpmi_yield();
return 0;
}
diff -u -r -N 03/src/libc/posix/unistd/write.c 04/src/libc/posix/unistd/write.c
--- 03/src/libc/posix/unistd/write.c Sun Aug 31 22:49:14 1997
+++ 04/src/libc/posix/unistd/write.c Wed Oct 22 21:25:58 1997
@@ -21,8 +21,8 @@
write(int handle, const void* buffer, size_t count)
{
const char *buf = (const char *)buffer;
- int bytes_in_tb = 0;
- int offset_into_buf = 0;
+ unsigned bytes_in_tb = 0;
+ unsigned offset_into_buf = 0;
__dpmi_regs r;
ssize_t rv;
--------------754C11F2220E--
- Raw text -