b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <ordex@autistici.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org
Subject: [B.A.T.M.A.N.] [PATCH 11/16] batman-adv: Transform BATADV_LOG_BUFF(idx) into function
Date: Mon,  2 Jul 2012 01:43:41 +0200	[thread overview]
Message-ID: <1341186226-10549-12-git-send-email-ordex@autistici.org> (raw)
In-Reply-To: <1341186226-10549-1-git-send-email-ordex@autistici.org>

From: Sven Eckelmann <sven@narfation.org>

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 <sven@narfation.org>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
 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++;
 
-- 
1.7.9.4


  parent reply	other threads:[~2012-07-01 23:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-01 23:43 [B.A.T.M.A.N.] pull request: batman-adv 2012-07-01 Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 01/16] batman-adv: Prefix gateway enum with BATADV_ Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 02/16] batman-adv: Prefix hard-interface " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 03/16] batman-adv: Prefix types " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 04/16] batman-adv: Prefix packet " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 05/16] batman-adv: Prefix main " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 06/16] batman-adv: Prefix local debugfs structs with batadv_ Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 07/16] batman-adv: Prefix hash struct and typedef " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 08/16] batman-adv: Prefix local sysfs struct " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 09/16] batman-adv: Prefix packet structs " Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 10/16] batman-adv: Prefix types " Antonio Quartulli
2012-07-01 23:43 ` Antonio Quartulli [this message]
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 12/16] batman-adv: Remove bat_ prefix from bat_{debugfs, sysfs}.{c, h} Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 13/16] batman-adv: Remove space before semicolon Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 14/16] batman-adv: Fix alignment after opened parentheses Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 15/16] batman-adv: fix counter summary length Antonio Quartulli
2012-07-01 23:43 ` [B.A.T.M.A.N.] [PATCH 16/16] batman-adv: Don't leak information through uninitialized packet fields Antonio Quartulli
2012-07-02  0:58 ` [B.A.T.M.A.N.] pull request: batman-adv 2012-07-01 David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1341186226-10549-12-git-send-email-ordex@autistici.org \
    --to=ordex@autistici.org \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).