From patchwork Mon Apr 8 22:19:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 2412121 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id D58BCDFB78 for ; Mon, 8 Apr 2013 22:19:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935322Ab3DHWTN (ORCPT ); Mon, 8 Apr 2013 18:19:13 -0400 Received: from perches-mx.perches.com ([206.117.179.246]:57947 "EHLO labridge.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934642Ab3DHWTM (ORCPT ); Mon, 8 Apr 2013 18:19:12 -0400 Received: from [173.51.221.202] (account joe@perches.com HELO [192.168.1.152]) by labridge.com (CommuniGate Pro SMTP 5.0.14) with ESMTPA id 20868924; Mon, 08 Apr 2013 15:19:11 -0700 Message-ID: <1365459552.2029.20.camel@joe-AO722> Subject: Re: [PATCH 5/6] mac80211: stringify another plink state From: Joe Perches To: Thomas Pedersen Cc: johannes@sipsolutions.net, linux-wireless@vger.kernel.org, devel@lists.open80211s.org Date: Mon, 08 Apr 2013 15:19:12 -0700 In-Reply-To: <1365456467.2029.16.camel@joe-AO722> References: <1365444377-9959-1-git-send-email-thomas@cozybit.com> <1782507887.154.1365455855469.JavaMail.mail@webmail12> <1365456467.2029.16.camel@joe-AO722> X-Mailer: Evolution 3.6.2-0ubuntu0.1 Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Mon, 2013-04-08 at 14:27 -0700, Joe Perches wrote: > On Mon, 2013-04-08 at 11:06 -0700, Thomas Pedersen wrote: > > The patch "mac80211: stringify mesh peering events" missed > > an opportunity to print the peering state as a string. > > Perhaps it's better to use functions for these instead of > indexing in case an index is somehow incorrectly set. Maybe: net/mac80211/mesh_plink.c | 73 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 51 insertions(+), 22 deletions(-) --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/mac80211/mesh_plink.c b/net/mac80211/mesh_plink.c index 937e06f..55d01d4 100644 --- a/net/mac80211/mesh_plink.c +++ b/net/mac80211/mesh_plink.c @@ -37,27 +37,55 @@ enum plink_event { CLS_IGNR }; -static const char * const mplstates[] = { - [NL80211_PLINK_LISTEN] = "LISTEN", - [NL80211_PLINK_OPN_SNT] = "OPN-SNT", - [NL80211_PLINK_OPN_RCVD] = "OPN-RCVD", - [NL80211_PLINK_CNF_RCVD] = "CNF_RCVD", - [NL80211_PLINK_ESTAB] = "ESTAB", - [NL80211_PLINK_HOLDING] = "HOLDING", - [NL80211_PLINK_BLOCKED] = "BLOCKED" -}; +static const char *mplstates(enum nl80211_plink_state state) +{ + switch (state) { + case NL80211_PLINK_LISTEN: + return "LISTEN"; + case NL80211_PLINK_OPN_SNT: + return "OPN-SNT"; + case NL80211_PLINK_OPN_RCVD: + return "OPN-RCVD"; + case NL80211_PLINK_CNF_RCVD: + return "CNF_RCVD"; + case NL80211_PLINK_ESTAB: + return "ESTAB"; + case NL80211_PLINK_HOLDING: + return "HOLDING"; + case NL80211_PLINK_BLOCKED: + return "BLOCKED"; + default: + break; + } + return "UNKNOWN_PLINK_STATE"; +} -static const char * const mplevents[] = { - [PLINK_UNDEFINED] = "NONE", - [OPN_ACPT] = "OPN_ACPT", - [OPN_RJCT] = "OPN_RJCT", - [OPN_IGNR] = "OPN_IGNR", - [CNF_ACPT] = "CNF_ACPT", - [CNF_RJCT] = "CNF_RJCT", - [CNF_IGNR] = "CNF_IGNR", - [CLS_ACPT] = "CLS_ACPT", - [CLS_IGNR] = "CLS_IGNR" -}; +static const char *mplevents(enum plink_event event) +{ + switch (event) { + case PLINK_UNDEFINED: + return "NONE"; + case OPN_ACPT: + return "OPN_ACPT"; + case OPN_RJCT: + return "OPN_RJCT"; + case OPN_IGNR: + return "OPN_IGNR"; + case CNF_ACPT: + return "CNF_ACPT"; + case CNF_RJCT: + return "CNF_RJCT"; + case CNF_IGNR: + return "CNF_IGNR"; + case CLS_ACPT: + return "CLS_ACPT"; + case CLS_IGNR: + return "CLS_IGNR"; + default: + break; + } + return "UNKNOWN_PLINK_EVENT"; +} static int mesh_plink_frame_tx(struct ieee80211_sub_if_data *sdata, enum ieee80211_self_protected_actioncode action, @@ -841,8 +869,9 @@ void mesh_rx_plink_frame(struct ieee80211_sub_if_data *sdata, } } - mpl_dbg(sdata, "peer %pM in state %s got event %s\n", mgmt->sa, - mplstates[sta->plink_state], mplevents[event]); + mpl_dbg(sdata, "peer %pM in state %d (%s) got event %d (%s)\n", + mgmt->sa, sta->plink_state, mplstates(sta->plink_state), + event, mplevents(event)); reason = 0; spin_lock_bh(&sta->lock); switch (sta->plink_state) {