* [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.
@ 2007-03-12 20:41 Scott Wood
2007-03-13 2:19 ` David Gibson
0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2007-03-12 20:41 UTC (permalink / raw)
To: paulus; +Cc: linuxppc-dev
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.
2007-03-12 20:41 [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr Scott Wood
@ 2007-03-13 2:19 ` David Gibson
2007-03-13 5:33 ` Mark A. Greer
2007-03-13 15:36 ` Scott Wood
0 siblings, 2 replies; 4+ messages in thread
From: David Gibson @ 2007-03-13 2:19 UTC (permalink / raw)
To: Scott Wood; +Cc: linuxppc-dev, paulus
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.
2007-03-13 2:19 ` David Gibson
@ 2007-03-13 5:33 ` Mark A. Greer
2007-03-13 15:36 ` Scott Wood
1 sibling, 0 replies; 4+ messages in thread
From: Mark A. Greer @ 2007-03-13 5:33 UTC (permalink / raw)
To: Scott Wood, paulus, linuxppc-dev
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:
> > 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 :)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr.
2007-03-13 2:19 ` David Gibson
2007-03-13 5:33 ` Mark A. Greer
@ 2007-03-13 15:36 ` Scott Wood
1 sibling, 0 replies; 4+ messages in thread
From: Scott Wood @ 2007-03-13 15:36 UTC (permalink / raw)
To: paulus, linuxppc-dev
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:
> > 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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-03-13 15:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-12 20:41 [PATCH 08/19] bootwrapper: Rename p and pp to anchor and anchorptr Scott Wood
2007-03-13 2:19 ` David Gibson
2007-03-13 5:33 ` Mark A. Greer
2007-03-13 15:36 ` Scott Wood
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).