linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Scott Wood <scottwood@freescale.com>
To: paulus@samba.org
Cc: linuxppc-dev@ozlabs.org
Subject: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.
Date: Mon, 12 Mar 2007 14:41:50 -0600	[thread overview]
Message-ID: <20070312204150.GH28545@ld0162-tx32.am.freescale.net> (raw)

This makes the meaning of "p" clearer, and increases the visual
difference between the two to avoid bugs such as the one fixed in
"Modify *pp, not *p, in ft_shuffle()".

Signed-off-by: Scott Wood <scottwood@freescale.com>
---
 arch/powerpc/boot/flatdevtree.c |   44 +++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/arch/powerpc/boot/flatdevtree.c b/arch/powerpc/boot/flatdevtree.c
index f2a29ca..0c8970e 100644
--- a/arch/powerpc/boot/flatdevtree.c
+++ b/arch/powerpc/boot/flatdevtree.c
@@ -215,23 +215,25 @@ static inline char *next_start(struct ft_cxt *cxt, enum ft_rgn_id r)
  * See if we can expand region rgn by nextra bytes by using up
  * free space after or before the region.
  */
-static int ft_shuffle(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
-		int nextra)
+static int ft_shuffle(struct ft_cxt *cxt, char **anchorptr,
+                      enum ft_rgn_id rgn, int nextra)
 {
-	char *p = *pp;
+	char *anchor = *anchorptr;
 	char *rgn_start, *rgn_end;
 
 	rgn_start = cxt->rgn[rgn].start;
 	rgn_end = rgn_start + cxt->rgn[rgn].size;
 	if (nextra <= 0 || rgn_end + nextra <= next_start(cxt, rgn)) {
 		/* move following stuff */
-		if (p < rgn_end) {
+		if (anchor < rgn_end) {
 			if (nextra < 0)
-				memmove(p, p - nextra, rgn_end - p + nextra);
+				memmove(anchor, anchor - nextra,
+				        rgn_end - anchor + nextra);
 			else
-				memmove(p + nextra, p, rgn_end - p);
+				memmove(anchor + nextra, anchor,
+				        rgn_end - anchor);
 			if (rgn == FT_STRUCT)
-				ft_node_update_after(cxt, p, nextra);
+				ft_node_update_after(cxt, anchor, nextra);
 		}
 		cxt->rgn[rgn].size += nextra;
 		if (rgn == FT_STRINGS)
@@ -241,12 +243,13 @@ static int ft_shuffle(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 	}
 	if (prev_end(cxt, rgn) <= rgn_start - nextra) {
 		/* move preceding stuff */
-		if (p > rgn_start) {
-			memmove(rgn_start - nextra, rgn_start, p - rgn_start);
+		if (anchor > rgn_start) {
+			memmove(rgn_start - nextra, rgn_start,
+			        anchor - rgn_start);
 			if (rgn == FT_STRUCT)
-				ft_node_update_before(cxt, p, -nextra);
+				ft_node_update_before(cxt, anchor, -nextra);
 		}
-		*pp -= nextra;
+		*anchorptr -= nextra;
 		cxt->rgn[rgn].start -= nextra;
 		cxt->rgn[rgn].size += nextra;
 		return 1;
@@ -254,22 +257,22 @@ static int ft_shuffle(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 	return 0;
 }
 
-static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
-			 int nextra)
+static int ft_make_space(struct ft_cxt *cxt, char **anchorptr,
+                         enum ft_rgn_id rgn, int nextra)
 {
 	unsigned long size, ssize, tot;
 	char *str, *next;
 	enum ft_rgn_id r;
 
 	if (!cxt->isordered) {
-		unsigned long rgn_off = *pp - cxt->rgn[rgn].start;
+		unsigned long rgn_off = *anchorptr - cxt->rgn[rgn].start;
 
 		if (!ft_reorder(cxt, nextra))
 			return 0;
 
-		*pp = cxt->rgn[rgn].start + rgn_off;
+		*anchorptr = cxt->rgn[rgn].start + rgn_off;
 	}
-	if (ft_shuffle(cxt, pp, rgn, nextra))
+	if (ft_shuffle(cxt, anchorptr, rgn, nextra))
 		return 1;
 
 	/* See if there is space after the strings section */
@@ -282,7 +285,8 @@ static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 		memmove(str, cxt->rgn[FT_STRINGS].start, ssize);
 		cxt->rgn[FT_STRINGS].start = str;
 		/* enough space now? */
-		if (rgn >= FT_STRUCT && ft_shuffle(cxt, pp, rgn, nextra))
+		if (rgn >= FT_STRUCT &&
+		    ft_shuffle(cxt, anchorptr, rgn, nextra))
 			return 1;
 	}
 
@@ -316,7 +320,7 @@ static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 				new_start = cxt->rgn[r].start + shift;
 				cxt->rgn[r].start = new_start;
 			}
-			*pp += shift;
+			*anchorptr += shift;
 			cxt->str_anchor += shift;
 		}
 
@@ -326,7 +330,7 @@ static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 		memmove(str, cxt->rgn[FT_STRINGS].start, ssize);
 		cxt->rgn[FT_STRINGS].start = str;
 
-		if (ft_shuffle(cxt, pp, rgn, nextra))
+		if (ft_shuffle(cxt, anchorptr, rgn, nextra))
 			return 1;
 	}
 
@@ -341,7 +345,7 @@ static int ft_make_space(struct ft_cxt *cxt, char **pp, enum ft_rgn_id rgn,
 		ft_node_update_after(cxt, cxt->rgn[FT_STRUCT].start, nextra);
 		cxt->rgn[FT_STRUCT].start = next;
 
-		if (ft_shuffle(cxt, pp, rgn, nextra))
+		if (ft_shuffle(cxt, anchorptr, rgn, nextra))
 			return 1;
 	}
 
-- 
1.5.0.3

             reply	other threads:[~2007-03-12 20:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-12 20:41 Scott Wood [this message]
2007-03-13  2:19 ` [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr David Gibson
2007-03-13  5:33   ` Mark A. Greer
2007-03-13 15:36   ` Scott Wood

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=20070312204150.GH28545@ld0162-tx32.am.freescale.net \
    --to=scottwood@freescale.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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).