From patchwork Sun Jul 1 23:43:41 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 168479 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id A5E952C01C0 for ; Mon, 2 Jul 2012 09:44:55 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752224Ab2GAXnw (ORCPT ); Sun, 1 Jul 2012 19:43:52 -0400 Received: from investici.nine.ch ([217.150.252.179]:23572 "EHLO confino.investici.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751718Ab2GAXnm (ORCPT ); Sun, 1 Jul 2012 19:43:42 -0400 Received: from [217.150.252.179] (confino [217.150.252.179]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id F3C29C86B6; Sun, 1 Jul 2012 23:43:40 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 confino.investici.org F3C29C86B6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=autistici.org; s=stigmate; t=1341186221; bh=F7kSV3sWAB/2QqQN8z9G3epHuRfXh1YLCUd+ne4Ddj4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=SZLrzBFtfDiwWCHBH/saK6uodEheORJpn9UprNheWG4oh0mrHucsSZMes2qxM6FJh RSTlVA23POZ4d2edDXfcVadz3ZhKpfV9bRsZYhT2YY0lFfpG0qk/DSAQ/yaZZLtI9j +Ij0Tg3jChe4wsMYdv+MMtkNQf8bPcNohL/An1Kw= From: Antonio Quartulli To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , Antonio Quartulli Subject: [PATCH 11/16] batman-adv: Transform BATADV_LOG_BUFF(idx) into function Date: Mon, 2 Jul 2012 01:43:41 +0200 Message-Id: <1341186226-10549-12-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.7.9.4 In-Reply-To: <1341186226-10549-1-git-send-email-ordex@autistici.org> References: <1341186226-10549-1-git-send-email-ordex@autistici.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sven Eckelmann The linux Documentation/CodingStyle says that: * Chapter 12: "inline functions are preferable to macros resembling functions" * Chapter 12.2: Depending on local variables with a magic name is bad * Chapter 12.3: Macros with arguments used as l-value are bad Signed-off-by: Sven Eckelmann Signed-off-by: Antonio Quartulli --- net/batman-adv/bat_debugfs.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/bat_debugfs.c b/net/batman-adv/bat_debugfs.c index db7b9bf..acf33e2 100644 --- a/net/batman-adv/bat_debugfs.c +++ b/net/batman-adv/bat_debugfs.c @@ -36,13 +36,21 @@ static struct dentry *batadv_debugfs; #ifdef CONFIG_BATMAN_ADV_DEBUG #define BATADV_LOG_BUFF_MASK (batadv_log_buff_len - 1) -#define BATADV_LOG_BUFF(idx) (debug_log->log_buff[(idx) & BATADV_LOG_BUFF_MASK]) -static int batadv_log_buff_len = BATADV_LOG_BUF_LEN; +static const int batadv_log_buff_len = BATADV_LOG_BUF_LEN; + +static char *batadv_log_char_addr(struct batadv_debug_log *debug_log, + size_t idx) +{ + return &debug_log->log_buff[idx & BATADV_LOG_BUFF_MASK]; +} static void batadv_emit_log_char(struct batadv_debug_log *debug_log, char c) { - BATADV_LOG_BUFF(debug_log->log_end) = c; + char *char_addr; + + char_addr = batadv_log_char_addr(debug_log, debug_log->log_end); + *char_addr = c; debug_log->log_end++; if (debug_log->log_end - debug_log->log_start > batadv_log_buff_len) @@ -109,6 +117,7 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, struct batadv_priv *bat_priv = file->private_data; struct batadv_debug_log *debug_log = bat_priv->debug_log; int error, i = 0; + char *char_addr; char c; if ((file->f_flags & O_NONBLOCK) && @@ -134,7 +143,9 @@ static ssize_t batadv_log_read(struct file *file, char __user *buf, while ((!error) && (i < count) && (debug_log->log_start != debug_log->log_end)) { - c = BATADV_LOG_BUFF(debug_log->log_start); + char_addr = batadv_log_char_addr(debug_log, + debug_log->log_start); + c = *char_addr; debug_log->log_start++;