Mercurial > pidgin.yaz
comparison libpurple/connection.c @ 21357:5a3242b676ad
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.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Sun, 14 Oct 2007 12:19:20 +0000 |
parents | c560286daede |
children | ba41f2a60253 |
comparison
equal
deleted
inserted
replaced
21356:be75cb19f548 | 21357:5a3242b676ad |
---|---|
506 const char *description) | 506 const char *description) |
507 { | 507 { |
508 PurpleConnectionUiOps *ops; | 508 PurpleConnectionUiOps *ops; |
509 | 509 |
510 g_return_if_fail(gc != NULL); | 510 g_return_if_fail(gc != NULL); |
511 g_return_if_fail(reason < PURPLE_NUM_REASONS); | 511 /* This sanity check relies on PURPLE_REASON_OTHER_ERROR being the |
512 * last member of the PurpleDisconnectReason enum in connection.h; if | |
513 * other reasons are added after it, this check should be updated. | |
514 */ | |
515 if (reason > PURPLE_REASON_OTHER_ERROR) { | |
516 purple_debug_error("connection", | |
517 "purple_connection_error_reason: reason %u isn't a " | |
518 "valid reason\n", reason); | |
519 reason = PURPLE_REASON_OTHER_ERROR; | |
520 } | |
512 | 521 |
513 if (description == NULL) { | 522 if (description == NULL) { |
514 purple_debug_error("connection", "purple_connection_error_reason: check `description != NULL' failed\n"); | 523 purple_debug_error("connection", "purple_connection_error_reason: check `description != NULL' failed\n"); |
515 description = _("Unknown error"); | 524 description = _("Unknown error"); |
516 } | 525 } |