diff options
author | Guy Harris <guy@alum.mit.edu> | 2015-01-13 13:00:59 -0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-01-13 21:01:28 +0000 |
commit | 9f5e4fb7a51741a286ce5bc92a6f335ed58587a2 (patch) | |
tree | 3e2a2634f036dc891270ee59f488b5a66386d285 | |
parent | 25f010b2696ccccab44545971f43784946b23ba8 (diff) | |
download | wireshark-9f5e4fb7a51741a286ce5bc92a6f335ed58587a2.tar.gz |
uat_load() and uat_save() return a success indication; use it.
Instead of always ignoring the return value, always check it, and only
report an error if it returns FALSE.
(Alternative: have it return NULL on success and a pointer to a
g_malloc()ed string on failure.)
Fix a comment while we're at it.
Change-Id: Icb72c9f47775b6552e3eb4fe5ddcc85482bfb5fb
Reviewed-on: https://code.wireshark.org/review/6528
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | caputils/airpcap_loader.c | 12 | ||||
-rw-r--r-- | epan/uat.c | 13 | ||||
-rw-r--r-- | ui/gtk/uat_gui.c | 17 | ||||
-rw-r--r-- | ui/qt/io_graph_dialog.cpp | 12 | ||||
-rw-r--r-- | ui/qt/sctp_chunk_statistics_dialog.cpp | 6 | ||||
-rw-r--r-- | ui/qt/uat_dialog.cpp | 7 |
6 files changed, 31 insertions, 36 deletions
diff --git a/caputils/airpcap_loader.c b/caputils/airpcap_loader.c index 28a42167d8..6ac4b2a633 100644 --- a/caputils/airpcap_loader.c +++ b/caputils/airpcap_loader.c @@ -165,9 +165,9 @@ get_wep_key(pref_t *pref, gpointer ud) /* This is just a sanity check. UAT should be loaded */ if (!uat->loaded) { - uat_load(uat, &err); - if (err != NULL) + if (!uat_load(uat, &err)) { + /* XXX - report the error */ g_free(err); return 1; } @@ -265,9 +265,9 @@ set_wep_key(pref_t *pref, gpointer ud _U_) { /* UAT will only be loaded if previous keys exist, so it may need to be loaded now */ - uat_load(uat, &err); - if (err != NULL) + if (!uat_load(uat, &err)) { + /* XXX - report the error */ g_free(err); return 1; } @@ -285,9 +285,9 @@ set_wep_key(pref_t *pref, gpointer ud _U_) uat_add_record(uat, &uat_key, TRUE); } - uat_save(uat, &err); - if (err != NULL) + if (!uat_save(uat, &err)) { + /* XXX - report the error */ g_free(err); return 1; } diff --git a/epan/uat.c b/epan/uat.c index 3194e8c852..ceafea8826 100644 --- a/epan/uat.c +++ b/epan/uat.c @@ -434,14 +434,13 @@ void uat_load_all(void) { for (i=0; i < all_uats->len; i++) { uat_t* u = (uat_t *)g_ptr_array_index(all_uats,i); - err = NULL; - if (!u->loaded) - uat_load(u, &err); - - if (err) { - report_failure("Error loading table '%s': %s",u->name,err); - g_free(err); + if (!u->loaded) { + err = NULL; + if (!uat_load(u, &err)) { + report_failure("Error loading table '%s': %s",u->name,err); + g_free(err); + } } } } diff --git a/ui/gtk/uat_gui.c b/ui/gtk/uat_gui.c index 2783dc5fcf..2703ac1a37 100644 --- a/ui/gtk/uat_gui.c +++ b/ui/gtk/uat_gui.c @@ -811,9 +811,7 @@ static void uat_cancel_cb(GtkWidget *button _U_, gpointer u) { if (uat->changed) { uat_clear(uat); - uat_load(uat, &err); - - if (err) { + if (!uat_load(uat, &err)) { report_failure("Error while loading %s: %s", uat->name, err); g_free(err); } @@ -842,9 +840,7 @@ static void uat_ok_cb(GtkButton *button _U_, gpointer u) { gchar *err = NULL; if (uat->changed) { - uat_save(uat, &err); - - if (err) { + if (!uat_save(uat, &err)) { report_failure("Error while saving %s: %s", uat->name, err); g_free(err); } @@ -872,15 +868,16 @@ static void uat_refresh_cb(GtkButton *button _U_, gpointer u) { uat_t *uat = (uat_t *)u; gchar *err = NULL; guint i; + gboolean success; uat_clear_cb(button, u); uat->from_global = TRUE; - uat_load(uat, &err); + success = uat_load(uat, &err); uat->from_global = FALSE; uat->changed = TRUE; - if (err) { + if (!success) { report_failure("Error while loading %s: %s", uat->name, err); g_free(err); } @@ -911,9 +908,7 @@ static void uat_yessave_cb(GtkWindow *w _U_, void *u) { window_delete_event_cb(uat->rep->unsaved_window, NULL, NULL); - uat_save(uat, &err); - - if (err) { + if (!uat_save(uat, &err)) { report_failure("Error while saving %s: %s", uat->name, err); g_free(err); } diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp index 997c56702f..5e49bfb493 100644 --- a/ui/qt/io_graph_dialog.cpp +++ b/ui/qt/io_graph_dialog.cpp @@ -561,8 +561,10 @@ void IOGraphDialog::reject() } } char* err = NULL; - uat_save(iog_uat_, &err); - g_free(err); + if (!uat_save(iog_uat_, &err)) { + /* XXX - report this error */ + g_free(err); + } } QDialog::reject(); @@ -1076,8 +1078,10 @@ void IOGraphDialog::loadProfileGraphs() NULL, io_graph_fields); char* err = NULL; - uat_load(iog_uat_, &err); - g_free(err); + if (!uat_load(iog_uat_, &err)) { + /* XXX - report the error */ + g_free(err); + } } diff --git a/ui/qt/sctp_chunk_statistics_dialog.cpp b/ui/qt/sctp_chunk_statistics_dialog.cpp index 216840668e..d5e2422eaf 100644 --- a/ui/qt/sctp_chunk_statistics_dialog.cpp +++ b/ui/qt/sctp_chunk_statistics_dialog.cpp @@ -1,4 +1,4 @@ -/* sctp_chunck_statistics_dialog.cpp +/* sctp_chunk_statistics_dialog.cpp * * Wireshark - Network traffic analyzer * By Gerald Combs <gerald@wireshark.org> @@ -279,8 +279,8 @@ void SCTPChunkStatisticsDialog::on_actionChunkTypePreferences_triggered() uat_t *uat = pref->varp.uat; uat_clear(uat); - uat_load(pref->varp.uat, &err); - if (err) { + if (!uat_load(pref->varp.uat, &err)) { + /* XXX - report this through the GUI */ printf("Error loading table '%s': %s",pref->varp.uat->name,err); g_free(err); } diff --git a/ui/qt/uat_dialog.cpp b/ui/qt/uat_dialog.cpp index 82fd89c8c7..ab96ad3257 100644 --- a/ui/qt/uat_dialog.cpp +++ b/ui/qt/uat_dialog.cpp @@ -499,9 +499,8 @@ void UatDialog::on_buttonBox_accepted() if (uat_->changed) { gchar *err = NULL; - uat_save(uat_, &err); - if (err) { + if (!uat_save(uat_, &err)) { report_failure("Error while saving %s: %s", uat_->name, err); g_free(err); } @@ -520,9 +519,7 @@ void UatDialog::on_buttonBox_rejected() if (uat_->changed) { gchar *err = NULL; uat_clear(uat_); - uat_load(uat_, &err); - - if (err) { + if (!uat_load(uat_, &err)) { report_failure("Error while loading %s: %s", uat_->name, err); g_free(err); } |