# HG changeset patch # User Ethan Blanton # Date 1209574827 0 # Node ID 5954c65ae4f43bd257f1fa8bc1928dd9e4df542d # Parent cc8903c59d6b74703f343e8eaa48333e7767f786 Don't count the size of an array at runtime if it's known at compile time. diff -r cc8903c59d6b -r 5954c65ae4f4 libpurple/protocols/jabber/usermood.c --- a/libpurple/protocols/jabber/usermood.c Wed Apr 30 08:46:51 2008 +0000 +++ b/libpurple/protocols/jabber/usermood.c Wed Apr 30 17:00:27 2008 +0000 @@ -147,7 +147,7 @@ static void do_mood_set_from_fields(PurpleConnection *gc, PurpleRequestFields *fields) { JabberStream *js; - int max_mood_idx; + const int max_mood_idx = sizeof(moodstrings) / sizeof(moodstrings[0]) - 1; int selected_mood = purple_request_fields_get_choice(fields, "mood"); if (!PURPLE_CONNECTION_IS_VALID(gc)) { @@ -157,9 +157,6 @@ js = gc->proto_data; - /* This is ugly, but protects us from unexpected values. */ - for (max_mood_idx = 0; moodstrings[max_mood_idx]; max_mood_idx++); - if (selected_mood < 0 || selected_mood >= max_mood_idx) { purple_debug_error("jabber", "Invalid mood index (%d) selected.\n", selected_mood); return;