im.pidgin.cpw.resiak.disconnectreason: b2e9a8ce6f5a4a868c5feda49eae12cf4ffeacab
resiak at soc.pidgin.im
resiak at soc.pidgin.im
Sun Oct 14 19:45:34 EDT 2007
-----------------------------------------------------------------
Revision: b2e9a8ce6f5a4a868c5feda49eae12cf4ffeacab
Ancestor: f97cb980adb380f09c2174d886b8e34dca56bdcd
Author: resiak at soc.pidgin.im
Date: 2007-10-14T12:19:20
Branch: im.pidgin.cpw.resiak.disconnectreason
Modified files:
libpurple/connection.c libpurple/connection.h
ChangeLog:
rlaager suggested using the last element of the PurpleDisconnectReason enum
for sanity checking, which sidesteps the "should NUM_REASONS be in or out of
the enum?" problem.
-------------- next part --------------
============================================================
--- libpurple/connection.c d0935204e5b050b7efd7f0bc029ceafaf2689dc8
+++ libpurple/connection.c 666ca510385a646f7e8c1c0f8a52215c0e1a2f41
@@ -508,7 +508,16 @@ purple_connection_error_reason (PurpleCo
PurpleConnectionUiOps *ops;
g_return_if_fail(gc != NULL);
- g_return_if_fail(reason < PURPLE_NUM_REASONS);
+ /* This sanity check relies on PURPLE_REASON_OTHER_ERROR being the
+ * last member of the PurpleDisconnectReason enum in connection.h; if
+ * other reasons are added after it, this check should be updated.
+ */
+ if (reason > PURPLE_REASON_OTHER_ERROR) {
+ purple_debug_error("connection",
+ "purple_connection_error_reason: reason %u isn't a "
+ "valid reason\n", reason);
+ reason = PURPLE_REASON_OTHER_ERROR;
+ }
if (description == NULL) {
purple_debug_error("connection", "purple_connection_error_reason: check `description != NULL' failed\n");
============================================================
--- libpurple/connection.h 3182743699c8b1b09f6af82850e2132800a35225
+++ libpurple/connection.h 23e4e627f4509264fd6de978ffe4a85139b5b49c
@@ -119,12 +119,13 @@ typedef enum
/** Some other error occured which fits into none of the other
* categories.
*/
+ /* purple_connection_error_reason() in connection.c uses the fact that
+ * this is the last member of the enum when sanity-checking; if other
+ * reasons are added after it, the check must be updated.
+ */
PURPLE_REASON_OTHER_ERROR = 15
} PurpleDisconnectReason;
-/** 1 more than the value of the last #PurpleDisconnectReason. */
-#define PURPLE_NUM_REASONS 16
-
#include <time.h>
#include "account.h"
More information about the Commits
mailing list