[PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.

Subsystems: linux for powerpc (32-bit and 64-bit), the rest

STALE7119d

4 messages, 3 authors, 2007-03-13 · open the first message on its own page

[PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.

From: Scott Wood <hidden>
Date: 2007-03-12 20:41:55

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 <redacted>
---
 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

Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.

From: David Gibson <hidden>
Date: 2007-03-13 02:19:55

On Mon, Mar 12, 2007 at 02:41:50PM -0600, Scott Wood wrote:
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()".
Hrm.  This does increase the visual difference, but honestly the
meaning of "anchor" is not notably more obvious to me than "p".

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.

From: Mark A. Greer <hidden>
Date: 2007-03-13 05:32:55

On Tue, Mar 13, 2007 at 01:19:55PM +1100, David Gibson wrote:
On Mon, Mar 12, 2007 at 02:41:50PM -0600, Scott Wood wrote:
quoted
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()".
Hrm.  This does increase the visual difference, but honestly the
meaning of "anchor" is not notably more obvious to me than "p".
Ditto :)

Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.

From: Scott Wood <hidden>
Date: 2007-03-13 15:36:48

On Tue, Mar 13, 2007 at 01:19:55PM +1100, David Gibson wrote:
On Mon, Mar 12, 2007 at 02:41:50PM -0600, Scott Wood wrote:
quoted
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()".
Hrm.  This does increase the visual difference, but honestly the
meaning of "anchor" is not notably more obvious to me than "p".
The idea was that it's where the caller holds on to when the data gets
moved around.  I agree that it's not a great name, but I couldn't think
of anything better (and previously, someone requested that I change the
name from p).  Any suggestions?

-Scott
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help