In the thread on the 21.4.9 release candidate, some signed/unsigned
operations were mentioned. Most turned out to be easy to fix. Here is
the patch. I'm sending this from the patched XEmacs. There are still
warnings from ccl_driver in mule-ccl.c. There are two signed variables,
i and j. They are compared like this:
if ((unsigned int)i < j)
Why the cast? I don't understand what is going on well enough to touch
it. Except for those, the only other warnings in my (Linux) build were
from unused parameters, missing initializers, and switch statements that
do not handle every possible case. Something similar may be necessary
for 21.5, but this patch does not apply cleanly.
lwlib/ChangeLog addition:
2002-08-21 Jerry James <james(a)xemacs.org>
* lwlib-Xlw.c (xlw_update_tab_control): Fix signed/unsigned operation.
* xlwtabs.c (TabsSetValues): Ditto.
* xlwtabs.c (TabsSelect): Ditto.
* xlwtabs.c (DrawTabs): Ditto.
src/ChangeLog addition:
2002-08-21 Jerry James <james(a)xemacs.org>
* chartab.c (check_category_char): Fix signed/unsigned operation.
* dumper.c (pdump_size_to_align): Ditto.
* dumper.c (pdump_scan_by_alignment): Ditto.
* dumper.c (pdump_dump_rtables): Ditto.
* dumper.c (pdump): Ditto.
* glyphs-eimage.c (tiff_instantiate): Ditto.
* redisplay-x.c (x_output_string): Ditto.
* redisplay.c (point_in_line_start_cache): Ditto.
* regex.c (regcomp): Ditto.
* glyphs.c (image_instance_layout): Remove tautological assert.
* event-Xt.c (x_to_emacs_keysym): Fix used uninitialized warning.
xemacs-21.4 source patch:
Diff command: cvs -q diff -uN
Files affected: src/regex.c src/redisplay.c src/redisplay-x.c src/glyphs.c
src/glyphs-eimage.c src/event-Xt.c src/dumper.c src/chartab.c lwlib/xlwtabs.c
lwlib/lwlib-Xlw.c
Index: lwlib/lwlib-Xlw.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/lwlib-Xlw.c,v
retrieving revision 1.8.2.1
diff -d -u -u -r1.8.2.1 lwlib-Xlw.c
--- lwlib/lwlib-Xlw.c 2001/10/23 08:35:22 1.8.2.1
+++ lwlib/lwlib-Xlw.c 2002/08/21 19:20:35
@@ -419,8 +419,7 @@
xlw_update_tab_control (widget_instance* instance, Widget widget, widget_value* val)
{
Widget* children;
- unsigned int num_children;
- int i;
+ unsigned int num_children, i;
widget_value *cur = 0;
XtRemoveAllCallbacks (widget, XtNcallback);
Index: lwlib/xlwtabs.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/lwlib/xlwtabs.c,v
retrieving revision 1.2.2.1
diff -d -u -u -r1.2.2.1 xlwtabs.c
--- lwlib/xlwtabs.c 2001/10/23 08:35:23 1.2.2.1
+++ lwlib/xlwtabs.c 2002/08/21 19:20:35
@@ -613,7 +613,7 @@
TabsWidget tw = (TabsWidget) new ;
Boolean needRedraw = False ;
Widget *childP ;
- int i ;
+ Cardinal i ;
if( tw->tabs.font != curtw->tabs.font ||
@@ -675,7 +675,7 @@
XtVaSetValues(w, XmNtraversalOn, True, 0) ;
#endif
- if( tab->tabs.row != tw->tabs.numRows-1 )
+ if( (Cardinal)tab->tabs.row != tw->tabs.numRows-1 )
TabsShuffleRows(tw) ;
@@ -1053,7 +1053,7 @@
Widget *childP ;
Position x,y ;
Dimension h = tw->tabs.tab_height ;
- int i ;
+ Cardinal i ;
#ifdef NEED_MOTIF
XmProcessTraversal (w, XmTRAVERSE_CURRENT) ;
@@ -1386,7 +1386,7 @@
DrawTabs(TabsWidget tw, Bool labels)
{
Widget *childP ;
- int i,j ;
+ Cardinal i,j ;
Dimension s = SHADWID ;
Dimension th = tw->tabs.tab_height ;
Position y ;
@@ -1404,11 +1404,11 @@
for(i=0; i<tw->tabs.numRows; ++i, y += th)
{
for( j=TabsNumChildren (tw), childP=tw->composite.children;
- --j >= 0; ++childP )
+ j > 0; --j, ++childP )
if( TabVisible(*childP) )
{
tab = (TabsConstraints)(*childP)->core.constraints;
- if( tab->tabs.row == i && *childP != tw->tabs.topWidget )
+ if( (Cardinal)tab->tabs.row==i && *childP != tw->tabs.topWidget )
DrawTab(tw, *childP, labels) ;
}
if( i != tw->tabs.numRows -1 )
Index: src/chartab.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/chartab.c,v
retrieving revision 1.14
diff -d -u -u -r1.14 chartab.c
--- src/chartab.c 2001/04/12 18:23:27 1.14
+++ src/chartab.c 2002/08/21 19:20:35
@@ -1625,7 +1625,7 @@
return not_p;
designator -= ' ';
- return bit_vector_bit (XBIT_VECTOR (temp), designator) ? !not_p : not_p;
+ return bit_vector_bit (XBIT_VECTOR (temp), designator) ? !not_p : (int)not_p;
}
DEFUN ("check-category-at", Fcheck_category_at, 2, 4, 0, /*
Index: src/dumper.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dumper.c,v
retrieving revision 1.2.2.1
diff -d -u -u -r1.2.2.1 dumper.c
--- src/dumper.c 2002/08/20 11:36:50 1.2.2.1
+++ src/dumper.c 2002/08/21 19:20:35
@@ -234,7 +234,7 @@
16, 1, 2, 1, 4, 1, 2, 1, 8, 1, 2, 1, 4, 1, 2, 1
};
-static inline unsigned int
+static inline int
pdump_size_to_align (size_t size)
{
return pdump_align_table[size % countof (pdump_align_table)];
@@ -818,17 +818,18 @@
for (align = ALIGNOF (max_align_t); align; align>>=1)
{
- size_t i;
- pdump_entry_list_elt *elt;
+ REGISTER size_t i;
+ REGISTER int j;
+ REGISTER pdump_entry_list_elt *elt;
for (i=0; i<lrecord_type_count; i++)
if (pdump_object_table[i].align == align)
for (elt = pdump_object_table[i].first; elt; elt = elt->next)
f (elt, lrecord_implementations_table[i]->description);
- for (i=0; i<pdump_struct_table.count; i++)
+ for (j=0; j<pdump_struct_table.count; j++)
{
- pdump_struct_list_elt list = pdump_struct_table.list[i];
+ pdump_struct_list_elt list = pdump_struct_table.list[j];
if (list.list.align == align)
for (elt = list.list.first; elt; elt = elt->next)
f (elt, list.sdesc->description);
@@ -870,7 +871,8 @@
static void
pdump_dump_rtables (void)
{
- size_t i;
+ REGISTER size_t i;
+ REGISTER int j;
pdump_entry_list_elt *elt;
pdump_reloc_table rt;
@@ -894,17 +896,17 @@
rt.count = 0;
PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
- for (i=0; i<pdump_struct_table.count; i++)
+ for (j=0; j<pdump_struct_table.count; j++)
{
- elt = pdump_struct_table.list[i].list.first;
- rt.desc = pdump_struct_table.list[i].sdesc->description;
- rt.count = pdump_struct_table.list[i].list.count;
+ elt = pdump_struct_table.list[j].list.first;
+ rt.desc = pdump_struct_table.list[j].sdesc->description;
+ rt.count = pdump_struct_table.list[j].list.count;
PDUMP_WRITE_ALIGNED (pdump_reloc_table, rt);
while (elt)
{
EMACS_INT rdata = pdump_get_entry (elt->obj)->save_offset;
- int j;
- for (j=0; j<elt->count; j++)
+ int k;
+ for (k=0; k<elt->count; k++)
{
PDUMP_WRITE_ALIGNED (EMACS_INT, rdata);
rdata += elt->size;
@@ -969,7 +971,8 @@
void
pdump (void)
{
- size_t i;
+ REGISTER size_t i;
+ REGISTER int j;
Lisp_Object t_console, t_device, t_frame;
int none;
pdump_header header;
@@ -1012,8 +1015,8 @@
pdump_opaque_data_list.count = 0;
depth = 0;
- for (i=0; i<Dynarr_length (pdump_root_objects); i++)
- pdump_register_object (* Dynarr_at (pdump_root_objects, i));
+ for (j=0; j<Dynarr_length (pdump_root_objects); j++)
+ pdump_register_object (* Dynarr_at (pdump_root_objects, j));
none = 1;
for (i=0; i<lrecord_type_count; i++)
@@ -1027,9 +1030,9 @@
if (!none)
return;
- for (i=0; i<(size_t)Dynarr_length (pdump_root_struct_ptrs); i++)
+ for (j=0; j<Dynarr_length (pdump_root_struct_ptrs); j++)
{
- pdump_root_struct_ptr info = Dynarr_at (pdump_root_struct_ptrs, i);
+ pdump_root_struct_ptr info = Dynarr_at (pdump_root_struct_ptrs, j);
pdump_register_struct (*(info.ptraddress), info.desc, 1);
}
Index: src/event-Xt.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/event-Xt.c,v
retrieving revision 1.47.2.1
diff -d -u -u -r1.47.2.1 event-Xt.c
--- src/event-Xt.c 2002/08/20 11:37:01 1.47.2.1
+++ src/event-Xt.c 2002/08/21 19:20:36
@@ -966,7 +966,7 @@
KeySym keysym = 0;
#ifdef HAVE_XIM
- int len;
+ int len = -1;
/* Some implementations of XmbLookupString don't return
XBufferOverflow correctly, so increase the size of the xim input
buffer from 64 to the more reasonable size 513, as Emacs has done.
Index: src/glyphs-eimage.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/glyphs-eimage.c,v
retrieving revision 1.9.2.2
diff -d -u -u -r1.9.2.2 glyphs-eimage.c
--- src/glyphs-eimage.c 2002/08/20 11:37:21 1.9.2.2
+++ src/glyphs-eimage.c 2002/08/21 19:20:36
@@ -1283,11 +1283,11 @@
rp = raster;
if (TIFFReadRGBAImage (unwind.tiff, width, height, raster, 0))
{
- for (i = height - 1; i >= 0; i--)
+ for (i = height; i > 0; i--)
{
/* This is to get around weirdness in the libtiff library where properly
made TIFFs will come out upside down. libtiff bug or jhod-brainlock? */
- rp = raster + (i * width);
+ rp = raster + ((i - 1) * width);
for (j = 0; j < width; j++)
{
*ep++ = (unsigned char)TIFFGetR(*rp);
Index: src/glyphs.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/glyphs.c,v
retrieving revision 1.27.2.1
diff -d -u -u -r1.27.2.1 glyphs.c
--- src/glyphs.c 2002/08/20 11:37:27 1.27.2.1
+++ src/glyphs.c 2002/08/21 19:20:37
@@ -1989,9 +1989,6 @@
if (yoffset != IMAGE_UNCHANGED_GEOMETRY)
XIMAGE_INSTANCE_YOFFSET (image_instance) = yoffset;
- assert (XIMAGE_INSTANCE_YOFFSET (image_instance) >= 0
- && XIMAGE_INSTANCE_XOFFSET (image_instance) >= 0);
-
/* If geometry is unspecified then get some reasonable values for it. */
if (width == IMAGE_UNSPECIFIED_GEOMETRY
||
Index: src/redisplay-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay-x.c,v
retrieving revision 1.25.2.2
diff -d -u -u -r1.25.2.2 redisplay-x.c
--- src/redisplay-x.c 2002/08/20 11:37:59 1.25.2.2
+++ src/redisplay-x.c 2002/08/21 19:20:38
@@ -1016,9 +1016,9 @@
upos = ascent - ((ascent + descent) / 2) + 1;
/* Generally, upos will be positive (above the baseline),so subtract */
- if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
+ if (dl->clip - upos < dl->descent)
{
- if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
+ if (uthick > dl->descent - dl->clip + upos)
uthick = dl->descent - dl->clip + upos;
if (uthick == 1)
Index: src/redisplay.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/redisplay.c,v
retrieving revision 1.62.2.2
diff -d -u -u -r1.62.2.2 redisplay.c
--- src/redisplay.c 2002/08/20 11:38:00 1.62.2.2
+++ src/redisplay.c 2002/08/21 19:20:39
@@ -7475,7 +7475,6 @@
struct buffer *b = XBUFFER (w->buffer);
line_start_cache_dynarr *cache = w->line_start_cache;
unsigned int top, bottom;
- EMACS_INT pos;
validate_line_start_cache (w);
w->line_cache_validation_override++;
@@ -7603,7 +7602,7 @@
while (1)
{
- unsigned int new_pos;
+ EMACS_INT pos, new_pos;
Bufpos start, end;
pos = (bottom + top + 1) >> 1;
Index: src/regex.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/regex.c,v
retrieving revision 1.25.2.2
diff -d -u -u -r1.25.2.2 regex.c
--- src/regex.c 2001/05/17 13:37:45 1.25.2.2
+++ src/regex.c 2002/08/21 19:20:40
@@ -6267,7 +6267,7 @@
if (cflags & REG_ICASE)
{
- unsigned i;
+ int i;
preg->translate = (char *) malloc (CHAR_SET_SIZE);
if (preg->translate == NULL)
--
Jerry James
http://www.ittc.ku.edu/~james/