aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2016-10-06 20:45:14 +1100
committerDavid Gibson <david@gibson.dropbear.id.au>2016-10-06 20:45:14 +1100
commit7b7a6be9ba159125a8e11b7ccc86233d17109187 (patch)
treead00aa2e6c7325a93281284cbf9700e2be278ba5
parentaea8860d831ed05a147a1896c15e1312a9a66917 (diff)
downloaddtc-7b7a6be9ba159125a8e11b7ccc86233d17109187.zip
dtc-7b7a6be9ba159125a8e11b7ccc86233d17109187.tar.gz
dtc-7b7a6be9ba159125a8e11b7ccc86233d17109187.tar.bz2
libfdt: Don't use 'index' as a local variable name
Using 'index' as a local variable name shadows the standard library index() function. This causes warnings on at least some compiler versions. The recently added overlay code has a number of instances of this. This patch replaces 'index' with 'poffset', since 'index' is being used to mean "offset within a property value" in these cases. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
-rw-r--r--libfdt/fdt_overlay.c20
-rw-r--r--tests/overlay.c30
2 files changed, 25 insertions, 25 deletions
diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
index c7e5508..322e7ad 100644
--- a/libfdt/fdt_overlay.c
+++ b/libfdt/fdt_overlay.c
@@ -234,9 +234,9 @@ static int overlay_update_local_node_references(void *fdto,
}
for (i = 0; i < (fixup_len / sizeof(uint32_t)); i++) {
- uint32_t adj_val, index;
+ uint32_t adj_val, poffset;
- index = fdt32_to_cpu(fixup_val[i]);
+ poffset = fdt32_to_cpu(fixup_val[i]);
/*
* phandles to fixup can be unaligned.
@@ -244,7 +244,7 @@ static int overlay_update_local_node_references(void *fdto,
* Use a memcpy for the architectures that do
* not support unaligned accesses.
*/
- memcpy(&adj_val, tree_val + index, sizeof(adj_val));
+ memcpy(&adj_val, tree_val + poffset, sizeof(adj_val));
adj_val = fdt32_to_cpu(adj_val);
adj_val += delta;
@@ -254,7 +254,7 @@ static int overlay_update_local_node_references(void *fdto,
tree_node,
name,
strlen(name),
- index,
+ poffset,
&adj_val,
sizeof(adj_val));
if (ret == -FDT_ERR_NOSPACE)
@@ -332,7 +332,7 @@ static int overlay_update_local_references(void *fdto, uint32_t delta)
* @path_len: number of path characters to consider
* @name: Name of the property holding the phandle reference in the overlay
* @name_len: number of name characters to consider
- * @index: Index in the overlay property where the phandle is stored
+ * @poffset: Offset within the overlay property where the phandle is stored
* @label: Label of the node referenced by the phandle
*
* overlay_fixup_one_phandle() resolves an overlay phandle pointing to
@@ -350,7 +350,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
int symbols_off,
const char *path, uint32_t path_len,
const char *name, uint32_t name_len,
- int index, const char *label)
+ int poffset, const char *label)
{
const char *symbol_path;
uint32_t phandle;
@@ -378,7 +378,7 @@ static int overlay_fixup_one_phandle(void *fdt, void *fdto,
phandle = cpu_to_fdt32(phandle);
return fdt_setprop_inplace_namelen_partial(fdto, fixup_off,
- name, name_len, index,
+ name, name_len, poffset,
&phandle, sizeof(phandle));
};
@@ -423,7 +423,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
uint32_t path_len, name_len;
uint32_t fixup_len;
char *sep, *endptr;
- int index, ret;
+ int poffset, ret;
fixup_end = memchr(value, '\0', len);
if (!fixup_end)
@@ -452,13 +452,13 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
if (!name_len)
return -FDT_ERR_BADOVERLAY;
- index = strtoul(sep + 1, &endptr, 10);
+ poffset = strtoul(sep + 1, &endptr, 10);
if ((*endptr != '\0') || (endptr <= (sep + 1)))
return -FDT_ERR_BADOVERLAY;
ret = overlay_fixup_one_phandle(fdt, fdto, symbols_off,
path, path_len, name, name_len,
- index, label);
+ poffset, label);
if (ret)
return ret;
} while (len > 0);
diff --git a/tests/overlay.c b/tests/overlay.c
index e467b03..961ed60 100644
--- a/tests/overlay.c
+++ b/tests/overlay.c
@@ -34,9 +34,9 @@
/* 4k ought to be enough for anybody */
#define FDT_COPY_SIZE (4 * 1024)
-static int fdt_getprop_u32_by_index(void *fdt, const char *path,
- const char *name, int index,
- unsigned long *out)
+static int fdt_getprop_u32_by_poffset(void *fdt, const char *path,
+ const char *name, int poffset,
+ unsigned long *out)
{
const fdt32_t *val;
int node_off;
@@ -47,10 +47,10 @@ static int fdt_getprop_u32_by_index(void *fdt, const char *path,
return node_off;
val = fdt_getprop(fdt, node_off, name, &len);
- if (!val || (len < (sizeof(uint32_t) * (index + 1))))
+ if (!val || (len < (sizeof(uint32_t) * (poffset + 1))))
return -FDT_ERR_NOTFOUND;
- *out = fdt32_to_cpu(*(val + index));
+ *out = fdt32_to_cpu(*(val + poffset));
return 0;
}
@@ -141,14 +141,14 @@ static int fdt_overlay_local_phandle(void *fdt)
local_phandle = fdt_get_phandle(fdt, off);
CHECK(!local_phandle);
- CHECK(fdt_getprop_u32_by_index(fdt, "/test-node",
- "test-several-phandle",
- 0, &val));
+ CHECK(fdt_getprop_u32_by_poffset(fdt, "/test-node",
+ "test-several-phandle",
+ 0, &val));
CHECK(val != local_phandle);
- CHECK(fdt_getprop_u32_by_index(fdt, "/test-node",
- "test-several-phandle",
- 1, &val));
+ CHECK(fdt_getprop_u32_by_poffset(fdt, "/test-node",
+ "test-several-phandle",
+ 1, &val));
CHECK(val != local_phandle);
return 0;
@@ -172,12 +172,12 @@ static int fdt_overlay_local_phandles(void *fdt)
test_phandle = fdt_get_phandle(fdt, off);
CHECK(!test_phandle);
- CHECK(fdt_getprop_u32_by_index(fdt, "/test-node",
- "test-phandle", 0, &val));
+ CHECK(fdt_getprop_u32_by_poffset(fdt, "/test-node",
+ "test-phandle", 0, &val));
CHECK(test_phandle != val);
- CHECK(fdt_getprop_u32_by_index(fdt, "/test-node",
- "test-phandle", 1, &val));
+ CHECK(fdt_getprop_u32_by_poffset(fdt, "/test-node",
+ "test-phandle", 1, &val));
CHECK(local_phandle != val);
return 0;