From a2e176a2d2f133af3bf89c38ab29d9dfa08bcdc1 Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Wed, 4 Jan 2012 23:05:52 -0500 Subject: [PATCH] More warning suppressions * lib-src/gnuslib.c (connect_to_unix_server): Use size_t for sz * src/ui/X11/event-Xt.c (x_reset_modifier_mapping): Add full prototype to auto functions * src/ui/glyphs-eimage.c (png_instantiate): use png_uint_32 in loop * src/ui/lwlib/xlwmenu.c (parameterize_string): add new offset to keep signedness in comparison * src/ui/X11/glyphs-x.c (x_subwindow_query_geometry): add prototyp * lib-src/gnuslib.c (connect_to_internet_server): Use size_t to compare with sizeof. * src/alloc.c (garbage_collect): ditto. * src/buffer.c (Fgenerate_new_buffer_name): ditto. * src/dumper.c (pdump_file_try): ditto. * src/dumper.c (pdump_load): ditto. * src/editfns.c (Fencode_time): ditto. * src/editfns.c (Fencode_btime): ditto. * src/editfns.c (Fcurrent_time_zone): ditto. * src/extents.c (print_extent_1): ditto. * src/mule/input-method-xlib.c (EmacsXtCvtStringToXIMStyles): ditto. * src/mule/input-method-xlib.c (describe_Window): ditto. * src/print.c (SXE_VSNPRINT_VA): ditto. * src/print.c (write_hex_ptr): ditto. * src/print.c (printing_major_badness): ditto. * src/process-unix.c (allocate_pty_the_old_fashioned_way): ditto. * src/process-unix.c (unix_open_network_stream): ditto. * src/process-unix.c (unix_open_network_server_stream): ditto. * src/process.c (make_process_internal): ditto. * src/strftime.c (add_num_time_t): ditto. * src/ui/TTY/objects-tty.c (Ffind_tty_color): ditto. * src/ui/TTY/objects-tty.c (Ftty_registered_color_list): ditto. * src/ui/TTY/redisplay-tty.c (term_get_fkeys_1): ditto. * src/ui/X11/device-x.c (read_locale_specific_resources): ditto. * src/ui/X11/device-x.c (x_init_device): ditto. * src/ui/X11/device-x.c (signal_if_x_error): ditto. * src/ui/X11/dialog-x.c (dbox_descriptor_to_widget_value): ditto. * src/ui/X11/event-Xt.c (x_keysym_to_emacs_keysym): ditto. * src/ui/X11/event-Xt.c (describe_event): ditto. * src/ui/X11/frame-x.c (color_to_string): ditto. * src/ui/X11/frame-x.c (x_set_initial_frame_size): ditto. * src/ui/X11/frame-x.c (Fx_window_id): ditto. * src/ui/X11/objects-x.c (truename_via_random_props): ditto. * src/ui/X11/scrollbar-x.c (x_create_scrollbar_instance): ditto. * src/ui/glyphs-eimage.c (tiff_error_func): ditto. * src/ui/glyphs-eimage.c (tiff_warning_func): ditto. * src/ui/lwlib/lwlib-Xaw.c (make_dialog): ditto. * src/ui/lwlib/lwlib-Xaw.c (make_dialog): ditto. * src/ui/lwlib/xlwgauge.c (GaugeExpose): ditto. * src/ui/lwlib/xlwgauge.c (MaxLabel): ditto. * src/ui/lwlib/xlwmenu.c (parameterize_string): ditto. * src/ui/lwlib/xlwtabs.c (XawTabsSetTop): ditto. * src/ui/redisplay.c (decode_mode_spec): ditto. * src/ui/redisplay.c (decode_mode_spec): ditto. * src/ui/redisplay.c (decode_mode_spec): ditto. Signed-off-by: Nelson Ferreira --- lib-src/gnuslib.c | 5 +++-- src/alloc.c | 8 ++++---- src/buffer.c | 2 +- src/dumper.c | 8 ++++---- src/editfns.c | 6 +++--- src/extents.c | 2 +- src/mule/input-method-xlib.c | 9 +++++---- src/print.c | 6 +++--- src/process-unix.c | 10 +++++----- src/process.c | 2 +- src/strftime.c | 2 +- src/ui/TTY/objects-tty.c | 4 ++-- src/ui/TTY/redisplay-tty.c | 2 +- src/ui/X11/device-x.c | 20 ++++++++++---------- src/ui/X11/dialog-x.c | 2 +- src/ui/X11/event-Xt.c | 15 +++++++++------ src/ui/X11/frame-x.c | 6 +++--- src/ui/X11/glyphs-x.c | 4 ++++ src/ui/X11/objects-x.c | 2 +- src/ui/X11/scrollbar-x.c | 2 +- src/ui/glyphs-eimage.c | 7 ++++--- src/ui/lwlib/lwlib-Xaw.c | 4 ++-- src/ui/lwlib/xlwgauge.c | 4 ++-- src/ui/lwlib/xlwmenu.c | 14 +++++++++----- src/ui/lwlib/xlwtabs.c | 2 +- src/ui/redisplay.c | 6 +++--- 26 files changed, 84 insertions(+), 70 deletions(-) diff --git a/lib-src/gnuslib.c b/lib-src/gnuslib.c index b056d6a..d665b30 100644 --- a/lib-src/gnuslib.c +++ b/lib-src/gnuslib.c @@ -247,7 +247,7 @@ static int connect_to_unix_server(void) { int s; /* connected socket descriptor */ struct sockaddr_un server; /* for unix connections */ - int sz; + size_t sz; if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { perror(progname); @@ -389,7 +389,8 @@ static int connect_to_internet_server(char *serverhost, unsigned short port) #endif /* AUTH_MAGIC_COOKIE */ len = snprintf(buf, sizeof(buf), "%s\n", DEFAUTH_NAME); - assert(len >= 0 && len < sizeof(buf)); + assert(len >= 0); + assert((size_t)len < sizeof(buf)); t = write(s, buf, len); if(t != len) { fprintf(stderr, "%s: unable to send auth", progname); diff --git a/src/alloc.c b/src/alloc.c index ab31f2d..55af853 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -4970,7 +4970,7 @@ Garbage collection happens automatically if you cons more than lcrecord_stats[i].bytes_freed; sz = snprintf(buf, sizeof(buf), "%s-storage", name); - assert(sz >=0 && sz < sizeof(buf)); + assert(sz >=0 && (size_t)sz < sizeof(buf)); pl = gc_plist_hack(buf, lcrecord_stats[i].bytes_in_use, pl); /* Okay, simple pluralization check for @@ -4979,7 +4979,7 @@ Garbage collection happens automatically if you cons more than sz = snprintf(buf, sizeof(buf), "%ses-freed", name); else sz = snprintf(buf, sizeof(buf), "%ss-freed", name); - assert(sz >=0 && sz < sizeof(buf)); + assert(sz >=0 && (size_t)sz < sizeof(buf)); if (lcrecord_stats[i].instances_freed != 0) pl = gc_plist_hack(buf, lcrecord_stats[i]. @@ -4988,7 +4988,7 @@ Garbage collection happens automatically if you cons more than sz = snprintf(buf, sizeof(buf), "%ses-on-free-list", name); else sz = snprintf(buf, sizeof(buf), "%ss-on-free-list", name); - assert(sz >=0 && sz < sizeof(buf)); + assert(sz >=0 && (size_t)sz < sizeof(buf)); if (lcrecord_stats[i].instances_on_free_list != 0) pl = gc_plist_hack(buf, lcrecord_stats[i]. @@ -4997,7 +4997,7 @@ Garbage collection happens automatically if you cons more than sz = snprintf(buf, sizeof(buf), "%ses-used", name); else sz = snprintf(buf, sizeof(buf), "%ss-used", name); - assert(sz >=0 && sz < sizeof(buf)); + assert(sz >=0 && (size_t)sz < sizeof(buf)); pl = gc_plist_hack(buf, lcrecord_stats[i].instances_in_use, pl); diff --git a/src/buffer.c b/src/buffer.c index 0718a59..734cb7b 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -705,7 +705,7 @@ even if a buffer with that name exists. count = 1; while (1) { prt = snprintf(number, sizeof(number), "<%d>", ++count); - assert(prt>=0 && prt < sizeof(number)); + assert(prt>=0 && (size_t)prt < sizeof(number)); gentemp = concat2(name, build_string(number)); if (!NILP(ignore)) { tem = Fstring_equal(gentemp, ignore); diff --git a/src/dumper.c b/src/dumper.c index 9e56aa0..8987436 100644 --- a/src/dumper.c +++ b/src/dumper.c @@ -1284,7 +1284,7 @@ static int pdump_file_try(char *exe_path, size_t size) sz = snprintf(w, size, "-%d.%d.%d-%08x.dmp", EMACS_MAJOR_VERSION, EMACS_MINOR_VERSION, EMACS_BETA_VERSION, dump_id); - if (sz >=0 && sz < size && pdump_file_get(exe_path)) { + if (sz >=0 && (size_t)sz < size && pdump_file_get(exe_path)) { if (pdump_load_check()) { return 1; } @@ -1293,7 +1293,7 @@ static int pdump_file_try(char *exe_path, size_t size) #endif /* EMACS_BETA_VERSION */ sz = snprintf(w, size, "-%08x.dmp", dump_id); - if (sz >=0 && sz < size && pdump_file_get(exe_path)) { + if (sz >=0 && (size_t)sz < size && pdump_file_get(exe_path)) { if (pdump_load_check()) { return 1; } @@ -1301,7 +1301,7 @@ static int pdump_file_try(char *exe_path, size_t size) } sz = snprintf(w, size, ".dmp"); - if (sz >=0 && sz < size && pdump_file_get(exe_path)) { + if (sz >=0 && (size_t)sz < size && pdump_file_get(exe_path)) { if (pdump_load_check()) { return 1; } @@ -1422,7 +1422,7 @@ int pdump_load(const char *argv0) /* Oh well, let's have some kind of default */ int sz = snprintf(exe_path, sizeof(exe_path), "./%s", name); - assert(sz >= 0 && sz < sizeof(exe_path)); + assert(sz >= 0 && (size_t)sz < sizeof(exe_path)); break; } path = p + 1; diff --git a/src/editfns.c b/src/editfns.c index 98e7507..a32f51b 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -1352,7 +1352,7 @@ If you want them to stand for years in this century, you must do that yourself. int sz = snprintf(tzbuf, sizeof(tzbuf), "XXX%s%d:%02d:%02d", "-" + (XINT(zone) < 0), abszone / (60 * 60), (abszone / 60) % 60, abszone % 60); - assert(sz >= 0 && sz < sizeof(tzbuf)); + assert(sz >= 0 && (size_t)sz < sizeof(tzbuf)); tzstring = tzbuf; } else { error("Invalid time zone specification"); @@ -1427,7 +1427,7 @@ Like `encode-time' but return a big integer time instead. int sz = snprintf(tzbuf, sizeof(tzbuf), "XXX%s%d:%02d:%02d", "-" + (XINT(zone) < 0), abszone / (60 * 60), (abszone / 60) % 60, abszone % 60); - assert(sz>=0 && sz < sizeof(tzbuf)); + assert(sz>=0 && (size_t)sz < sizeof(tzbuf)); tzstring = tzbuf; } else error("Invalid time zone specification"); @@ -1566,7 +1566,7 @@ the data it can't find. int sz = snprintf(buf, sizeof(buf), "%c%02d%02d", (offset < 0 ? '-' : '+'), am / 60, am % 60); - assert(sz>=0 && sz < sizeof(buf)); + assert(sz>=0 && (size_t)sz < sizeof(buf)); s = buf; } return list2(make_int(offset), build_string(s)); diff --git a/src/extents.c b/src/extents.c index e5c3ab8..226a17c 100644 --- a/src/extents.c +++ b/src/extents.c @@ -3140,7 +3140,7 @@ print_extent_1(Lisp_Object obj, Lisp_Object printcharfun, int escapeflag) sz=snprintf(bp, sizeof(buf)-2, "%ld, %ld", XINT(Fextent_start_position(obj)), XINT(Fextent_end_position(obj))); - assert(sz>=0 && sz<(sizeof(buf)-2)); + assert(sz>=0 && (size_t)sz<(sizeof(buf)-2)); } bp += strlen(bp); *bp++ = (extent_end_open_p(anc) ? ')' : ']'); diff --git a/src/mule/input-method-xlib.c b/src/mule/input-method-xlib.c index 7c10248..ef5c0bd 100644 --- a/src/mule/input-method-xlib.c +++ b/src/mule/input-method-xlib.c @@ -714,7 +714,7 @@ EmacsXtCvtStringToXIMStyles ( "Cannot convert string \"%s\" to type XIMStyles.\n" "Using default string \"%s\" instead.\n", fromVal->addr, DefaultXIMStyles); - assert(len >= 0 && len < sizeof(buf)); + assert(len >= 0 && (size_t)len < sizeof(buf)); XtAppWarningMsg(the_app_con, "wrongParameters", "cvtStringToXIMStyle", "XtToolkitError", @@ -939,9 +939,10 @@ void describe_Window (Window win) { char xwincmd[128]; - if ( snprintf (xwincmd, sizeof(xwincmd), - "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2", - (int) win, (int) win) < sizeof(xwincmd) ) { + int sz = snprintf (xwincmd, sizeof(xwincmd), + "xwininfo -id 0x%x >&2; xwininfo -events -id 0x%x >&2", + (int) win, (int) win); + if ( sz >= 0 && (size_t) sz < sizeof(xwincmd) ) { int exit_code = system (xwincmd); if ( exit_code != 0 ) stderr_out("command '%s' failed with exit code %d", diff --git a/src/print.c b/src/print.c index 58789f6..9b95721 100644 --- a/src/print.c +++ b/src/print.c @@ -144,7 +144,7 @@ std_handle_out_external(FILE * stream, Lisp_Object lstream, size *= 2; \ XMALLOC_OR_ALLOCA(buf,size,type); \ ret = 0; \ - } else if ( ret > size ) { \ + } else if ( (size_t)ret > (size_t)size ) { \ /* We need more space, so we need to allocate it */ \ XMALLOC_UNBIND(buf,size,spec); \ size = ret + 1; \ @@ -565,7 +565,7 @@ void write_hex_ptr(void* value, Lisp_Object stream) { char buf[sizeof(value)*2+1]; int n = snprintf(buf,sizeof(buf),"0x%p",value); - assert(n>=0 && n=0 && (size_t)n= 0 && len < sizeof(buf)); + assert(len >= 0 && (size_t)len < sizeof(buf)); /* Don't abort or signal if called from debug_print() or already crashing */ diff --git a/src/process-unix.c b/src/process-unix.c index 1af232f..a9a1296 100644 --- a/src/process-unix.c +++ b/src/process-unix.c @@ -376,7 +376,7 @@ static int allocate_pty_the_old_fashioned_way(void) PTY_NAME_SPRINTF; #else sz = snprintf(pty_name, sizeof(pty_name), "/dev/pty%c%x", c, i); - assert(sz >= 0 && sz < sizeof(pty_name)); + assert(sz >= 0 && (size_t)sz < sizeof(pty_name)); #endif /* no PTY_NAME_SPRINTF */ if (sxemacs_stat(pty_name, &stb) < 0) { @@ -391,9 +391,9 @@ static int allocate_pty_the_old_fashioned_way(void) #ifdef PTY_TTY_NAME_SPRINTF PTY_TTY_NAME_SPRINTF; #else - int sz = snprintf(pty_name, sizeof(pty_name), + sz = snprintf(pty_name, sizeof(pty_name), "/dev/tty%c%x", c, i); - assert(sz >= 0 && sz < sizeof(pty_name)); + assert(sz >= 0 && (size_t)sz < sizeof(pty_name)); #endif /* no PTY_TTY_NAME_SPRINTF */ if (access(pty_name, R_OK | W_OK) == 0) { setup_pty(fd); @@ -1674,7 +1674,7 @@ unix_open_network_stream(Lisp_Object name, Lisp_Object host, if (INTP(service)) { int sz= snprintf(portbuf, sizeof(portbuf), "%ld", (long)XINT(service)); - assert(sz >= 0 && sz < sizeof(portbuf)); + assert(sz >= 0 && (size_t)sz < sizeof(portbuf)); portstring = portbuf; port = htons((unsigned short)XINT(service)); } else { @@ -2126,7 +2126,7 @@ unix_open_network_server_stream(Lisp_Object name, Lisp_Object host, if (INTP(service)) { int sz = snprintf(portbuf, sizeof(portbuf), "%ld", (long)XINT(service)); - assert(sz >= 0 && sz < sizeof(portbuf)); + assert(sz >= 0 && (size_t)sz < sizeof(portbuf)); portstring = portbuf; port = htons((unsigned short)XINT(service)); } else { diff --git a/src/process.c b/src/process.c index 4e345a5..cb5b035 100644 --- a/src/process.c +++ b/src/process.c @@ -478,7 +478,7 @@ Lisp_Object make_process_internal(Lisp_Object name) if (NILP(tem)) break; sz = snprintf(suffix, sizeof(suffix), "<%d>", i); - assert(sz>=0 && sz=0 && (size_t)sz 16) abort(); length = snprintf(buf, sizeof(buf), "%lu", (unsigned long)num); - assert(length >= 0 && length= 0 && (size_t)lengthmaxcolors); - assert(sz >= 0 && sz < sizeof(term_name)); + assert(sz >= 0 && (size_t)sz < sizeof(term_name)); sym_term = Fintern(make_string((Bufbyte*)term_name,strlen(term_name)),Qnil); default_color_slist = color_slist = get_term_color_alias_slist(sym_term,0); if ( ! EQ(color_slist,Qnil) ) { @@ -347,7 +347,7 @@ DEVICE defaults to the selected device if omitted. Lisp_Object sym_term; int sz = snprintf(term_name,sizeof(term_name),"default-%d-color", CONSOLE_TTY_DATA(console)->maxcolors); - assert(sz>=0 && sz < sizeof(term_name)); + assert(sz>=0 && (size_t)sz < sizeof(term_name)); sym_term = Fintern(make_string((Bufbyte*)term_name,strlen(term_name)),Qnil); color_slist = get_term_color_alias_slist(sym_term,0); } diff --git a/src/ui/TTY/redisplay-tty.c b/src/ui/TTY/redisplay-tty.c index 9e8d8b2..c8c8485 100644 --- a/src/ui/TTY/redisplay-tty.c +++ b/src/ui/TTY/redisplay-tty.c @@ -1453,7 +1453,7 @@ static Lisp_Object term_get_fkeys_1(Lisp_Object function_key_map) char *sequence = tgetstr(fcap, address); if (sequence) { int sz = snprintf(fkey, sizeof(fkey), "f%d", i); - assert(sz >= 0 && sz < sizeof(fkey)); + assert(sz >= 0 && (size_t)sz < sizeof(fkey)); Fdefine_key(function_key_map, build_ext_string(sequence, Qbinary), diff --git a/src/ui/X11/device-x.c b/src/ui/X11/device-x.c index 622106f..ccb39bd 100644 --- a/src/ui/X11/device-x.c +++ b/src/ui/X11/device-x.c @@ -591,7 +591,7 @@ read_locale_specific_resources(Display *dpy) char path[strlen(data_dir) + strlen(locale) + 7]; int sz = snprintf(path, sizeof(path), "%s%s/Emacs", data_dir, locale); - assert(sz >= 0 && sz < sizeof(path)); + assert(sz >= 0 && (size_t)sz < sizeof(path)); if (!access(path, R_OK)) { XrmCombineFileDatabase(path, &db, False); } @@ -608,7 +608,7 @@ read_locale_specific_resources(Display *dpy) int sz = snprintf(path, sizeof(path), "%sapp-defaults/%s/Emacs", data_dir, locale); - assert(sz >= 0 && sz < sizeof(path)); + assert(sz >= 0 && (size_t)sz < sizeof(path)); if (!access(path, R_OK)) { XrmCombineFileDatabase(path, &db, False); } @@ -720,9 +720,9 @@ static void x_init_device(struct device *d, Lisp_Object props) XrmValue value; int sz = snprintf(buf1, sizeof(buf1), "%s.emacsVisual", app_name); - assert(sz >= 0 && sz < sizeof(buf1)); + assert(sz >= 0 && (size_t)sz < sizeof(buf1)); sz = snprintf(buf2, sizeof(buf2), "%s.EmacsVisual", app_class); - assert(sz >= 0 && sz < sizeof(buf2)); + assert(sz >= 0 && (size_t)sz < sizeof(buf2)); if (XrmGetResource(XtDatabase(dpy), buf1, buf2, &type, &value) == True) { @@ -782,10 +782,10 @@ static void x_init_device(struct device *d, Lisp_Object props) PseudoColor, check to see if the user specified that we need a private colormap */ if (visual == DefaultVisual(dpy, screen)) { - int sz = snprintf(buf1, sizeof(buf1), "%s.privateColormap", app_name); - assert(sz >= 0 && sz < sizeof(buf1)); + sz = snprintf(buf1, sizeof(buf1), "%s.privateColormap", app_name); + assert(sz >= 0 && (size_t)sz < sizeof(buf1)); sz = snprintf(buf2, sizeof(buf2), "%s.PrivateColormap", app_class); - assert(sz >= 0 && sz < sizeof(buf2)); + assert(sz >= 0 && (size_t)sz < sizeof(buf2)); if ((visual->class == PseudoColor) && (XrmGetResource @@ -1151,17 +1151,17 @@ int signal_if_x_error(Display * dpy, int resumable_p) return 0; data = Qnil; sz = snprintf(buf, sizeof(buf), "0x%X", (unsigned int)last_error.resourceid); - assert(sz >= 0 && sz < sizeof(buf)); + assert(sz >= 0 && (size_t)sz < sizeof(buf)); data = Fcons(build_string(buf), data); { char num[32]; sz = snprintf(num, sizeof(num), "%d", last_error.request_code); - assert(sz >= 0 && sz < sizeof(num)); + assert(sz >= 0 && (size_t)sz < sizeof(num)); XGetErrorDatabaseText(last_error.display, "XRequest", num, "", buf, sizeof(buf)); if (!*buf) { sz = snprintf(buf, sizeof(buf), "Request-%d", last_error.request_code); - assert(sz >=0 && sz < sizeof(buf)); + assert(sz >=0 && (size_t)sz < sizeof(buf)); } data = Fcons(build_string(buf), data); } diff --git a/src/ui/X11/dialog-x.c b/src/ui/X11/dialog-x.c index 3c67ada..dfcfa84 100644 --- a/src/ui/X11/dialog-x.c +++ b/src/ui/X11/dialog-x.c @@ -229,7 +229,7 @@ static widget_value *dbox_descriptor_to_widget_value(Lisp_Object keys) "%c%dBR%d", type, lbuttons + rbuttons, rbuttons); - assert(sz >= 0 && sz < sizeof(tmp_dbox_name)); + assert(sz >= 0 && (size_t)sz < sizeof(tmp_dbox_name)); dbox = xmalloc_widget_value(); dbox->name = xstrdup(tmp_dbox_name); dbox->contents = kids; diff --git a/src/ui/X11/event-Xt.c b/src/ui/X11/event-Xt.c index 087c601..b4d8d51 100644 --- a/src/ui/X11/event-Xt.c +++ b/src/ui/X11/event-Xt.c @@ -512,11 +512,14 @@ x_reset_modifier_mapping(struct device *d) KeySym last_sym = 0; KeyCode code = xd->x_modifier_keymap->modifiermap [modifier_index * mkpm + modifier_key]; - auto inline void modbarf() __attribute__((always_inline)); - auto inline void modwarn() __attribute__((always_inline)); - auto inline void store_modifier() + auto inline void modbarf(const char *name, const char *other) __attribute__((always_inline)); - auto inline void check_modifier() + auto inline void modwarn(const char *name, + int old, const char *other) + __attribute__((always_inline)); + auto inline void store_modifier(const char *name, int *old) + __attribute__((always_inline)); + auto inline void check_modifier(const char *name, int mask) __attribute__((always_inline)); auto inline void modbarf(const char *name, const char *other) @@ -1100,7 +1103,7 @@ x_keysym_to_emacs_keysym(KeySym keysym, int simple_p) int sz = snprintf(buf, sizeof(buf), "unknown-keysym-0x%X", (int)keysym); - assert(sz>=0 && sz < sizeof(buf)); + assert(sz>=0 && (size_t)sz < sizeof(buf)); return KEYSYM(buf); } } @@ -2734,7 +2737,7 @@ static void describe_event(XEvent * event) int sz = snprintf(buf, sizeof(buf), "%s%s", x_event_name(event->type), event->xany.send_event ? " (send)" : ""); - assert(sz >= 0 && sz < sizeof(buf)); + assert(sz >= 0 && (size_t)sz < sizeof(buf)); stderr_out("%-30s", buf); switch (event->type) { case FocusIn: diff --git a/src/ui/X11/frame-x.c b/src/ui/X11/frame-x.c index 8367fe1..d709600 100644 --- a/src/ui/X11/frame-x.c +++ b/src/ui/X11/frame-x.c @@ -473,7 +473,7 @@ static Lisp_Object color_to_string(Widget w, unsigned long pixel) color.pixel = pixel; XQueryColor(XtDisplay(w), w->core.colormap, &color); sz = snprintf(buf, sizeof(buf), "#%04x%04x%04x", color.red, color.green, color.blue); - assert(sz>=0 && sz < sizeof(buf)); + assert(sz>=0 && (size_t)sz < sizeof(buf)); return build_string(buf); } @@ -711,7 +711,7 @@ x_set_initial_frame_size(struct frame *f, int flags, int x, int y, else if (ussize) sz = snprintf(shell_geom, sizeof(shell_geom), "=%dx%d", w, h); - assert(sz >=0 && sz < sizeof(shell_geom)); + assert(sz >=0 && (size_t)sz < sizeof(shell_geom)); if (uspos || ussize) { temp = xnew_atomic_array(char, 1 + strlen(shell_geom)); strcpy(temp, shell_geom); @@ -2105,7 +2105,7 @@ a string. struct frame *f = decode_x_frame(frame); int sz = snprintf(str, sizeof(str), "%lu", XtWindow(FRAME_X_TEXT_WIDGET(f))); - assert(sz >= 0 && sz < sizeof(str)); + assert(sz >= 0 && (size_t)sz < sizeof(str)); return build_string(str); } diff --git a/src/ui/X11/glyphs-x.c b/src/ui/X11/glyphs-x.c index 6888c8c..ba3b46b 100644 --- a/src/ui/X11/glyphs-x.c +++ b/src/ui/X11/glyphs-x.c @@ -2224,6 +2224,10 @@ static int x_widget_border_width(void) return DEFAULT_WIDGET_BORDER_WIDTH * 2; } +void +x_subwindow_query_geometry(Lisp_Object image_instance, + int *width, int *height); + void x_subwindow_query_geometry(Lisp_Object image_instance, int *width, int *height) diff --git a/src/ui/X11/objects-x.c b/src/ui/X11/objects-x.c index af30648..6419630 100644 --- a/src/ui/X11/objects-x.c +++ b/src/ui/X11/objects-x.c @@ -629,7 +629,7 @@ static Extbyte *truename_via_random_props(Display * dpy, XFontStruct * font) "-%s-%s-%s-%s-%s-%s-%ld-%ld-%ld-%ld-%s-%ld-%s-%s", foundry, family, weight, slant, setwidth, add_style, pixel, point, res_x, res_y, spacing, avg_width, registry, encoding); - assert(sz>=0 && sz < sizeof(composed_name)); + assert(sz>=0 && (size_t)sz < sizeof(composed_name)); ok = 1; FAIL: diff --git a/src/ui/X11/scrollbar-x.c b/src/ui/X11/scrollbar-x.c index c3f0ce9..0e06a97 100644 --- a/src/ui/X11/scrollbar-x.c +++ b/src/ui/X11/scrollbar-x.c @@ -102,7 +102,7 @@ x_create_scrollbar_instance(struct frame *f, int vertical, SCROLLBAR_X_ID(instance) = new_lwlib_id(); sz = snprintf(buffer, sizeof(buffer), "scrollbar_%d", SCROLLBAR_X_ID(instance)); - assert(sz >= 0 && sz < sizeof(buffer)); + assert(sz >= 0 && (size_t)sz < sizeof(buffer)); SCROLLBAR_X_NAME(instance) = xstrdup(buffer); #if defined (LWLIB_SCROLLBARS_MOTIF) || defined (LWLIB_SCROLLBARS_LUCID) || \ defined (LWLIB_SCROLLBARS_ATHENA3D) diff --git a/src/ui/glyphs-eimage.c b/src/ui/glyphs-eimage.c index e3fc1e4..18f2153 100644 --- a/src/ui/glyphs-eimage.c +++ b/src/ui/glyphs-eimage.c @@ -957,7 +957,8 @@ png_instantiate(Lisp_Object image_instance, Lisp_Object instantiator, &interlace_type, NULL, NULL); { - int y, pass; + png_uint_32 y; + int pass; int passes = 0; png_bytep row_pointers[height]; @@ -1211,7 +1212,7 @@ static void tiff_error_func(const char *module, const char *fmt, ...) va_start(vargs, fmt); n = vsnprintf(tiff_err_data.err_str, sizeof(tiff_err_data.err_str), fmt, vargs); - assert(n>=0 && n < sizeof(tiff_err_data.err_str)); + assert(n>=0 && (size_t)n < sizeof(tiff_err_data.err_str)); va_end(vargs); /* return to setjmp point */ @@ -1227,7 +1228,7 @@ static void tiff_warning_func(const char *module, const char *fmt, ...) va_start(vargs, fmt); n = vsnprintf(warn_str, sizeof(warn_str), fmt, vargs); - assert(n>=0 && n < sizeof(warn_str)); + assert(n>=0 && (size_t)n < sizeof(warn_str)); va_end(vargs); warn_when_safe(Qtiff, Qinfo, "%s - %s", module, warn_str); } diff --git a/src/ui/lwlib/lwlib-Xaw.c b/src/ui/lwlib/lwlib-Xaw.c index 0f32f5a..acdae40 100644 --- a/src/ui/lwlib/lwlib-Xaw.c +++ b/src/ui/lwlib/lwlib-Xaw.c @@ -395,7 +395,7 @@ make_dialog(const char *name, Widget parent, Boolean pop_up_p, XtSetArg(av[ac], XtNresizable, True); ac++; sz = snprintf(button_name, sizeof(button_name), "button%d", ++bc); - assert(sz >= 0 && sz < sizeof(button_name)); + assert(sz >= 0 && (size_t)sz < sizeof(button_name)); button = XtCreateManagedWidget(button_name, commandWidgetClass, dialog, av, ac); } @@ -454,7 +454,7 @@ make_dialog(const char *name, Widget parent, Boolean pop_up_p, XtSetArg(av[ac], XtNresizable, True); ac++; sz = snprintf(button_name, sizeof(button_name), "button%d", ++bc); - assert(sz >= 0 && sz < sizeof(button_name)); + assert(sz >= 0 && (size_t)sz < sizeof(button_name)); button = XtCreateManagedWidget(button_name, commandWidgetClass, dialog, av, ac); } diff --git a/src/ui/lwlib/xlwgauge.c b/src/ui/lwlib/xlwgauge.c index b6478b4..c308e9e 100644 --- a/src/ui/lwlib/xlwgauge.c +++ b/src/ui/lwlib/xlwgauge.c @@ -459,7 +459,7 @@ static void GaugeExpose(Widget w, XEvent * event, Region region) "%d", v0 + i * (v1 - v0) / (gw->gauge.nlabels - 1)); - assert(n >= 0 && n < sizeof(label)); + assert(n >= 0 && (size_t)n < sizeof(label)); } else s = gw->gauge.labels[i]; @@ -899,7 +899,7 @@ static void MaxLabel(GaugeWidget gw, Dimension * wid, /* max label width */ if (gw->gauge.labels == NULL) { /* numeric labels */ int sz = snprintf(lbl = lstr, sizeof(lstr), "%d", v0 + i * dv / n); - assert(sz >= 0 && sz < sizeof(lstr)); + assert(sz >= 0 && (size_t)sz < sizeof(lstr)); } else lbl = gw->gauge.labels[i]; diff --git a/src/ui/lwlib/xlwmenu.c b/src/ui/lwlib/xlwmenu.c index b25921f..7b067d7 100644 --- a/src/ui/lwlib/xlwmenu.c +++ b/src/ui/lwlib/xlwmenu.c @@ -581,7 +581,8 @@ static char *parameterize_string(const char *string, const char *value) off_t offset = percent-string; if (percent[1] == '%') { /* it's a real % */ - assert( res_left >= (1 + offset) ); + assert( offset >=0 && + res_left >= (size_t)(1 + offset)); /* incl % */ strncat(result, string, 1 + offset); res_left -= 1 + offset; @@ -598,7 +599,8 @@ static char *parameterize_string(const char *string, const char *value) } else if (*p == '-') { /* right pad */ right_pad++; } else if (*p == '1') { /* param and terminator */ - assert( res_left >= offset ); + assert( offset >= 0 && + res_left >= (size_t)offset ); res_left -= offset; strncat(result, string, offset); if (value[0] != '\0') { @@ -615,9 +617,11 @@ static char *parameterize_string(const char *string, const char *value) break; /* out of for() loop */ } else { /* bogus, copy the format as is */ /* out of for() loop */ - assert( res_left >= (1+ p - string) ); - strncat(result, string, 1 + p - string); - res_left -= 1 + p - string; + off_t remain = 1 + p - string; + assert( remain >=0 && + res_left >= (size_t)remain ); + strncat(result, string, remain); + res_left -= remain; string = (*p ? &p[1] : p); offset = percent - string; break; diff --git a/src/ui/lwlib/xlwtabs.c b/src/ui/lwlib/xlwtabs.c index 8a34596..18abf45 100644 --- a/src/ui/lwlib/xlwtabs.c +++ b/src/ui/lwlib/xlwtabs.c @@ -1236,7 +1236,7 @@ void XawTabsSetTop(Widget w, Bool callCallbacks) int n = snprintf(line, sizeof(line), "XawTabsSetTop: widget \"%.64s\" is not the child of a tabs widget.", XtName(w)); - assert(n >= 0 && n < sizeof(line)); + assert(n >= 0 && (size_t)n < sizeof(line)); XtAppWarning(XtWidgetToApplicationContext(w), line); return; } diff --git a/src/ui/redisplay.c b/src/ui/redisplay.c index 12da833..0abf104 100644 --- a/src/ui/redisplay.c +++ b/src/ui/redisplay.c @@ -6669,7 +6669,7 @@ static void decode_mode_spec(struct window *w, Emchar spec, int type) const size_t order_strmax = sizeof(f->order_count)*3+2; char *writable_str = alloca_array(char, order_strmax); int n = snprintf(writable_str, order_strmax, "-%d", f->order_count); - assert(n>=0 && n < order_strmax); + assert(n>=0 && (size_t)n < order_strmax); str = writable_str; } #endif /* HAVE_TTY */ @@ -6760,7 +6760,7 @@ static void decode_mode_spec(struct window *w, Emchar spec, int type) percent = 99; n = snprintf(buf, sizeof(buf), "%d%%", percent); - assert(n>=0 && n < sizeof(buf)); + assert(n>=0 && (size_t)n < sizeof(buf)); Dynarr_add_many(mode_spec_bufbyte_string, (Bufbyte *) buf, strlen(buf)); @@ -6809,7 +6809,7 @@ static void decode_mode_spec(struct window *w, Emchar spec, int type) n = snprintf(buf, sizeof(buf), "Top%d%%", percent); else n = snprintf(buf, sizeof(buf), "%d%%", percent); - assert(n>=0 && n < sizeof(buf)); + assert(n>=0 && (size_t)n < sizeof(buf)); Dynarr_add_many(mode_spec_bufbyte_string, (Bufbyte *) buf, strlen(buf)); -- 2.25.1