SUPERCEDES APPROVE COMMIT 21.5
"Stephen J. Turnbull" <stephen(a)xemacs.org> wrote:
>>>>> "Jerry" == Jerry James
<james(a)xemacs.org> writes:
Jerry> Second, it was *after* I expanded CURCHARSIZE that the
Jerry> static checker then complained about CHARSIZE. Weird, huh?
Jerry> I guess it was working its way backward up the dataflow
Jerry> path and complained about the first item it saw that seemed
Jerry> wrong to it.
OK. I just thought that if this was one of the tools the shop you're
visiting is developing, they might like to know about the anomoly.
Yes, thanks. Actually, that was a run of somebody else's checker. I've
got quite a collection of them here, and am comparing them in various
ways. We are actually developing our own, too (where "we" means "I";
I'm the only developer on the project, although other people are lobbing
ideas at me). The XEmacs code base has proved to be extremely effective
at showing the limitations of the various checkers. :-)
One big problem is the use of function pointers. Most checkers can't
deal with them at all, although a few try to do pointer analysis. If
you don't know what function you are pointing to, you can't very well
analyze what a call to that function is going to do. Function pointers
passed to external libraries for use as callbacks are particularly
troublesome, since the library code isn't around to analyze.
Jerry> If you would like me to put those macros back,
that's fine.
Jerry> As you note, a good optimizing compiler should do the job,
Jerry> anyway.
I think it's a good idea. The original author (Ben, I suppose)
thought that all those "things" were somehow "the same". IMO we
should either change none or change all.
Okay, I'll update the patch to put them back.
Jerry> And that CURSIZE macro is bizarre. Would you object to
me
Jerry> "fixing" it to be an rvalue? As it stands, it's violating
Jerry> the C99 aliasing rules, apparently for no reason.
Please do! I spent about 5 minutes checking to make sure that the
lvalue-ness was bogus. Let's not put anybody else through that. If
lvalue-ness becomes useful, surely that person will know how to
rewrite the macro for lvalue-ness.
No can do. It is used as an lvalue, on line 4480 of window.c. I'm just
going to leave it alone.
I wonder if that might not confuse checkers and optimizers, too,
although they can probably do what I did, just in 4 nanoseconds. :-)
The checkers don't seem to have any trouble with it.
I am also putting back the if (d) { ... } in device-x.c, and extending
it by one line, based on the other thread. We already printed an error
message; I am not going to print another one if d is NULL. If somebody
else wants to do so, be my guest.
So here is the patch I am actually committing.
Index: ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/ChangeLog,v
retrieving revision 1.977
diff -d -u -r1.977 ChangeLog
--- ChangeLog 2006/06/19 18:49:21 1.977
+++ ChangeLog 2006/06/21 17:26:03
@@ -1,5 +1,19 @@
2006-06-19 Jerry James <james(a)xemacs.org>
+ * device-x.c (x_IO_error_handler): Do not dereference d if it is
+ NULL.
+ * dialog-x.c (dbox_selection_callback): Ensure f is non-NULL, then
+ dereference it, not the other way around.
+ * emacs.c (main_1): restart is always 0 here.
+ * extents.c (detach_all_extents): Call extent_list_delete_all with
+ a non-NULL parameter only.
+ * glyphs-widget.c (widget_query_geometry): Guard against possibly
+ NULL width and height.
+ * window.c (change_window_height): Restore use of CURCHARSIZE
+ removed by 2006-06-16 change, to preserve the abstraction.
+
+2006-06-19 Jerry James <james(a)xemacs.org>
+
* frame-x.c (x_set_frame_properties): Remove casts to silence GCC
warnings about a missing sentinel.
Index: device-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/device-x.c,v
retrieving revision 1.66
diff -d -u -r1.66 device-x.c
--- device-x.c 2005/11/25 01:41:59 1.66
+++ device-x.c 2006/06/21 17:26:03
@@ -1215,8 +1215,10 @@
Xlib might just decide to exit(). So we mark the offending
console for deletion and throw to top level. */
if (d)
- enqueue_magic_eval_event (io_error_delete_device, dev);
- DEVICE_X_BEING_DELETED (d) = 1;
+ {
+ enqueue_magic_eval_event (io_error_delete_device, dev);
+ DEVICE_X_BEING_DELETED (d) = 1;
+ }
Fthrow (Qtop_level, Qnil);
RETURN_NOT_REACHED (0);
Index: dialog-x.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/dialog-x.c,v
retrieving revision 1.15
diff -d -u -r1.15 dialog-x.c
--- dialog-x.c 2004/09/20 19:19:38 1.15
+++ dialog-x.c 2006/06/21 17:26:03
@@ -104,7 +104,7 @@
ourselves. */
#ifdef EXTERNAL_WIDGET
/* #### Not sure if this special case is necessary. */
- if (!FRAME_X_EXTERNAL_WINDOW_P (f) && f)
+ if (f && !FRAME_X_EXTERNAL_WINDOW_P (f))
#else
if (f)
#endif
Index: emacs.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/emacs.c,v
retrieving revision 1.167
diff -d -u -r1.167 emacs.c
--- emacs.c 2006/05/06 17:55:59 1.167
+++ emacs.c 2006/06/21 17:26:04
@@ -1395,7 +1395,7 @@
inhibit_site_modules = inhibit_site_modules_save;
if (initialized)
- run_temacs_argc = restart ? -2 : -1;
+ run_temacs_argc = -1;
else
purify_flag = 1;
}
Index: extents.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/extents.c,v
retrieving revision 1.65
diff -d -u -r1.65 extents.c
--- extents.c 2006/02/27 16:29:25 1.65
+++ extents.c 2006/06/21 17:26:04
@@ -1455,11 +1455,11 @@
set_extent_start (e, -1);
set_extent_end (e, -1);
}
- }
- /* But we need to clear all the lists containing extents or
- havoc will result. */
- extent_list_delete_all (data->extents);
+ /* But we need to clear all the lists containing extents or
+ havoc will result. */
+ extent_list_delete_all (data->extents);
+ }
soe_invalidate (object);
}
}
Index: glyphs-widget.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/glyphs-widget.c,v
retrieving revision 1.18
diff -d -u -r1.18 glyphs-widget.c
--- glyphs-widget.c 2005/11/26 11:46:08 1.18
+++ glyphs-widget.c 2006/06/21 17:26:04
@@ -569,21 +569,21 @@
IMAGE_INSTANCE_WIDGET_FACE (ii),
&w, &h, domain);
/* Adjust the size for borders. */
- if (IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
+ if (width && IMAGE_INSTANCE_SUBWINDOW_H_RESIZEP (ii))
*width = w + 2 * widget_instance_border_width (ii);
- if (IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
+ if (height && IMAGE_INSTANCE_SUBWINDOW_V_RESIZEP (ii))
*height = h + 2 * widget_instance_border_width (ii);
}
}
/* Finish off with dynamic sizing. */
- if (!NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
+ if (width && !NILP (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii)))
{
dynamic_width =
eval_within_redisplay (IMAGE_INSTANCE_WIDGET_WIDTH_SUBR (ii));
if (INTP (dynamic_width))
*width = XINT (dynamic_width);
}
- if (!NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
+ if (height && !NILP (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii)))
{
dynamic_height =
eval_within_redisplay (IMAGE_INSTANCE_WIDGET_HEIGHT_SUBR (ii));
Index: window.c
===================================================================
RCS file: /pack/xemacscvs/XEmacs/xemacs/src/window.c,v
retrieving revision 1.91
diff -d -u -r1.91 window.c
--- window.c 2006/06/19 18:19:38 1.91
+++ window.c 2006/06/21 17:26:04
@@ -4380,7 +4380,7 @@
{
int new_pixsize;
sizep = &CURSIZE (w);
- dim = window_char_width (w, 0);
+ dim = CURCHARSIZE (w);
new_pixsize = inpixels?(*sizep + delta):(dim+delta);
set_window_pixsize (window, new_pixsize, 0, 0);
return;
--
Jerry James, Assistant Professor james(a)xemacs.org
Computer Science Department
http://www.cs.usu.edu/~jerry/
Utah State University