Merge changes I8efee39a,I5295898f into main am: 1fe80c59e9 am: 9da6d57591
Original change: https://android-review.googlesource.com/c/platform/external/dtc/+/2784352 Change-Id: Ibd8df9868d097e36b8def39a1c655f58e42cb640 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
committed by
Automerger Merge Worker
commit
f25c58e67f
@@ -263,7 +263,7 @@ int fdt_path_offset_namelen(const void *fdt, const char *path, int namelen)
|
|||||||
|
|
||||||
FDT_RO_PROBE(fdt);
|
FDT_RO_PROBE(fdt);
|
||||||
|
|
||||||
if (namelen < 1)
|
if (!can_assume(VALID_INPUT) && namelen <= 0)
|
||||||
return -FDT_ERR_BADPATH;
|
return -FDT_ERR_BADPATH;
|
||||||
|
|
||||||
/* see if we have an alias */
|
/* see if we have an alias */
|
||||||
|
|||||||
@@ -48,10 +48,13 @@ static void check_path_offset(void *fdt, char *path, int offset)
|
|||||||
verbose_printf("Checking offset of \"%s\" is %d...\n", path, offset);
|
verbose_printf("Checking offset of \"%s\" is %d...\n", path, offset);
|
||||||
|
|
||||||
rc = fdt_path_offset(fdt, path);
|
rc = fdt_path_offset(fdt, path);
|
||||||
|
if (rc == offset)
|
||||||
|
return;
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
FAIL("fdt_path_offset(\"%s\") failed: %s",
|
FAIL("fdt_path_offset(\"%s\") failed: %s",
|
||||||
path, fdt_strerror(rc));
|
path, fdt_strerror(rc));
|
||||||
if (rc != offset)
|
else
|
||||||
FAIL("fdt_path_offset(\"%s\") returned incorrect offset"
|
FAIL("fdt_path_offset(\"%s\") returned incorrect offset"
|
||||||
" %d instead of %d", path, rc, offset);
|
" %d instead of %d", path, rc, offset);
|
||||||
}
|
}
|
||||||
@@ -102,6 +105,7 @@ int main(int argc, char *argv[])
|
|||||||
check_path_offset(fdt, "/subnode@2/subsubnode", subsubnode2_offset2);
|
check_path_offset(fdt, "/subnode@2/subsubnode", subsubnode2_offset2);
|
||||||
|
|
||||||
/* Test paths with extraneous separators */
|
/* Test paths with extraneous separators */
|
||||||
|
check_path_offset(fdt, "", -FDT_ERR_BADPATH);
|
||||||
check_path_offset(fdt, "//", 0);
|
check_path_offset(fdt, "//", 0);
|
||||||
check_path_offset(fdt, "///", 0);
|
check_path_offset(fdt, "///", 0);
|
||||||
check_path_offset(fdt, "//subnode@1", subnode1_offset);
|
check_path_offset(fdt, "//subnode@1", subnode1_offset);
|
||||||
@@ -110,6 +114,8 @@ int main(int argc, char *argv[])
|
|||||||
check_path_offset(fdt, "/subnode@2////subsubnode", subsubnode2_offset2);
|
check_path_offset(fdt, "/subnode@2////subsubnode", subsubnode2_offset2);
|
||||||
|
|
||||||
/* Test fdt_path_offset_namelen() */
|
/* Test fdt_path_offset_namelen() */
|
||||||
|
check_path_offset_namelen(fdt, "/subnode@1", -1, -FDT_ERR_BADPATH);
|
||||||
|
check_path_offset_namelen(fdt, "/subnode@1", 0, -FDT_ERR_BADPATH);
|
||||||
check_path_offset_namelen(fdt, "/subnode@1", 1, 0);
|
check_path_offset_namelen(fdt, "/subnode@1", 1, 0);
|
||||||
check_path_offset_namelen(fdt, "/subnode@1/subsubnode", 10, subnode1_offset);
|
check_path_offset_namelen(fdt, "/subnode@1/subsubnode", 10, subnode1_offset);
|
||||||
check_path_offset_namelen(fdt, "/subnode@1/subsubnode", 11, subnode1_offset);
|
check_path_offset_namelen(fdt, "/subnode@1/subsubnode", 11, subnode1_offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user