AmendHub

Download:

jcs

/

wallops

/

amendments

/

121

*: Cleanup panic messages


jcs made amendment 121 about 1 month ago
--- chatter.c Wed Sep 18 09:54:36 2024 +++ chatter.c Wed Sep 18 10:05:20 2024 @@ -230,7 +230,7 @@ chatter_add_tab(struct chatter *chatter, Rect *win_bou Cell cell = { 0, 0 }; if (channel && query_nick) - panic("add tab for both channel and query"); + panic("chatter_add_tab called for both channel and query"); if (conn) chatter_use_shadow(chatter); @@ -247,7 +247,7 @@ chatter_add_tab(struct chatter *chatter, Rect *win_bou tab = xmalloczero(sizeof(struct chatter_tab)); if (tab == NULL) - panic("Out of memory allocating for new tab"); + panic("Out of memory for new tab"); SLIST_APPEND(&chatter->tabs_list, tab, chatter_tab, list); chatter->ntabs++; tab->conn = conn; @@ -554,8 +554,11 @@ chatter_idle(struct focusable *focusable, EventRecord chatter_update_titlebar(chatter); } - if (chatter->shadow_refcnt != 0) - panic("shadow refcnt %d", chatter->shadow_refcnt); + if (chatter->shadow_refcnt != 0) { + warn("shadow refcnt %d", chatter->shadow_refcnt); + chatter_reveal_shadow(chatter); + chatter->shadow_refcnt = 0; + } } void @@ -1163,7 +1166,7 @@ chatter_printf(struct chatter *chatter, struct irc_con if (tab == NULL) { tab = SLIST_FIRST(&chatter->tabs_list); if (tab == NULL) - panic("chatter_printf: no tab"); + panic("chatter_printf: no tab for %s", dest_tab); } had_activity = tab->have_activity; @@ -1206,8 +1209,10 @@ chatter_printf(struct chatter *chatter, struct irc_con if (!stop_formatting && conv_buf[n] == '$') { if (in_this_style > 0) { scrp_rec->scrpNStyles++; - if (scrp_rec->scrpNStyles >= CHATTER_SCRAP_ELEMENTS) - panic("chatter_printf: too many elements"); + if (scrp_rec->scrpNStyles >= CHATTER_SCRAP_ELEMENTS) { + warn("chatter_printf: too many elements"); + return; + } prev_scrp_ele = scrp_ele; scrp_ele = &scrp_rec->scrpStyleTab[ scrp_rec->scrpNStyles - 1]; --- focusable.c Thu Sep 12 21:32:42 2024 +++ focusable.c Wed Sep 18 10:05:47 2024 @@ -75,7 +75,7 @@ focusable_add(struct focusable *focusable) } } if (focusable->id == -1) - panic("no focusable id"); + panic("No focusable id"); focusable_show(focusable); } --- irc.c Tue Sep 17 16:10:37 2024 +++ irc.c Wed Sep 18 10:07:39 2024 @@ -245,7 +245,7 @@ irc_send(struct irc_connection *conn, char *line, size short error; if (size > sizeof(conn->obuf)) - panic("irc_send: too much data %lu", size); + panic("irc_send: too much data (%lu)", size); if (conn->state < IRC_STATE_UNREGISTERED) return 0; @@ -365,7 +365,7 @@ irc_get_line(struct irc_connection *conn, size_t *rets } else { conn->ibuflen -= n + 2; if (conn->ibuflen < 0) - panic("bogus ibuflen %d", conn->ibuflen); + panic("irc_get_line: bogus ibuflen %d", conn->ibuflen); memmove(conn->ibuf, conn->ibuf + n + 2, conn->ibuflen); } return conn->line; @@ -1317,7 +1317,7 @@ irc_create_channel(struct irc_connection *conn, char * channel = xmalloczero(sizeof(struct irc_channel)); if (channel == NULL) - panic("Failed allocating memory for new channel"); + panic("Out of memory for new channel"); SLIST_APPEND(&conn->channels_list, channel, irc_channel, list); channel->connection = conn; strlcpy(channel->name, channame, sizeof(channel->name)); @@ -1429,7 +1429,8 @@ irc_add_nick_to_channel(struct irc_channel *channel, c sizeof(struct irc_channel_nick), channel->nicks_size); if (channel->nicks == NULL) - panic("out of memory allocating %ld for nicks", + panic("Out of memory for %d nicks (%ld bytes)", + channel->nnicks, sizeof(struct irc_channel_nick) * channel->nicks_size); memset(&channel->nicks[channel->nnicks], 0, sizeof(struct irc_channel_nick) * --- main.c Mon Sep 16 16:41:28 2024 +++ main.c Wed Sep 18 10:08:52 2024 @@ -70,22 +70,22 @@ main(void) _atexit(handle_exit); if (!(mbar = GetNewMBar(MBAR_ID))) - panic("no mbar"); + panic("No mbar"); SetMenuBar(mbar); if (!(apple_menu = GetMHandle(APPLE_MENU_ID))) - panic("no apple menu"); + panic("No Apple menu"); AddResMenu(apple_menu, 'DRVR'); if (!(file_menu = GetMHandle(FILE_MENU_ID))) - panic("no file menu"); + panic("No File menu"); if (!(edit_menu = GetMHandle(EDIT_MENU_ID))) - panic("no edit menu"); + panic("No Edit menu"); if (!(view_menu = GetMHandle(VIEW_MENU_ID))) - panic("no view menu"); + panic("No View menu"); if (!(ignore_menu = GetMenu(IGNORE_MENU_ID))) - panic("no ignore menu"); + panic("No Ignore menu"); InsertMenu(ignore_menu, -1); if (!(window_menu = GetMenu(WINDOW_MENU_ID))) - panic("no window menu"); + panic("No Window menu"); update_menu(); #ifdef MALLOC_DEBUG debug_menu = NewMenu(DEBUG_MENU_DUMP_ID, "\pDebug"); @@ -500,7 +500,7 @@ wallops_about(void) vers = (VersRecHndl)GetResource('vers', 1); if (!vers) - panic("no vers"); + panic("No vers"); /* * vers "long version string" is a pascal string after the --- settings.c Thu Sep 12 09:47:17 2024 +++ settings.c Wed Sep 18 10:14:03 2024 @@ -108,7 +108,8 @@ settings_load(void) error = PBHOpen(&pb, false); if (error) { if (error != fnfErr) - panic("Failed reading preferences file: %d", error); + panic("Failed reading preferences file %s: %d", PtoCstr(fn), + error); return false; } @@ -191,7 +192,7 @@ settings_save(struct settings *tsettings) return; create_failed: - panic("Failed creating preferences file: %d", error); + panic("Failed creating preferences file %s: %d", PtoCstr(fn), error); } bool @@ -278,7 +279,7 @@ settings_edit(bool use_defaults) sdata[0]) == 1); break; default: - panic("unknown setting type %d", s->type); + panic("Unknown setting type %d", s->type); } }