From 4cd2fd36d5c8c92fd9c84af52c5cb2bd7ef0e4d6 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sun, 18 May 2014 11:22:22 +0200 Subject: Add default cases to some switch statements This squelches several compiler warnings. Signed-off-by: Lukas Fleischer --- src/day.c | 15 +++++++++++++-- src/ui-day.c | 14 +++++++++++--- src/utils.c | 2 ++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/day.c b/src/day.c index 904c34a..15daa41 100644 --- a/src/day.c +++ b/src/day.c @@ -139,6 +139,8 @@ void day_item_erase_note(struct day_item *day) case RECUR_EVNT: erase_note(&day->item.rev->note); break; + default: + break; } } @@ -178,6 +180,8 @@ void day_item_add_exc(struct day_item *day, long date) case RECUR_APPT: recur_apoint_add_exc(day->item.rapt, date); break; + default: + break; } } @@ -646,9 +650,12 @@ struct day_item *day_cut_item(long date, int item_number) /* Paste a previously cut item. */ int day_paste_item(struct day_item *p, long date) { - switch (p->type) { - case 0: + if (!p->type) { + /* No previously cut item. */ return 0; + } + + switch (p->type) { case EVNT: event_paste_item(p->item.ev, date); break; @@ -701,6 +708,8 @@ void day_edit_note(struct day_item *p, const char *editor) case APPT: p->item.apt->note = note; break; + default: + break; } } @@ -720,5 +729,7 @@ void day_item_switch_notify(struct day_item *p) case APPT: apoint_switch_notify(p->item.apt); break; + default: + break; } } diff --git a/src/ui-day.c b/src/ui-day.c index 9401e18..8c34e77 100644 --- a/src/ui-day.c +++ b/src/ui-day.c @@ -393,6 +393,8 @@ void ui_day_item_edit(void) return; } break; + default: + break; } ui_calendar_monthly_view_cache_set_invalid(); @@ -436,6 +438,8 @@ void ui_day_item_pipe(void) case APPT: apoint_write(p->item.apt, fpout); break; + default: + break; } fclose(fpout); @@ -767,10 +771,12 @@ void ui_day_item_repeat(void) /* Free the current cut item, if any. */ void ui_day_item_cut_free(unsigned reg) { + if (!day_cut[reg].type) { + /* No previously cut item, don't free anything. */ + return; + } + switch (day_cut[reg].type) { - case 0: - /* No previous item, don't free anything. */ - break; case APPT: apoint_free(day_cut[reg].item.apt); break; @@ -783,6 +789,8 @@ void ui_day_item_cut_free(unsigned reg) case RECUR_EVNT: recur_event_free(day_cut[reg].item.rev); break; + default: + break; } } diff --git a/src/utils.c b/src/utils.c index 0bcd9db..02839c3 100644 --- a/src/utils.c +++ b/src/utils.c @@ -867,6 +867,8 @@ int parse_duration(const char *string, unsigned *duration) case STATE_HHMM_MM: return 0; break; + default: + break; } in = 0; -- cgit v1.2.3