From ec340077a8477020a347ee2e7cd7415efeec3898 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 3 Feb 2023 09:13:46 -0600 Subject: scripts/dtc: Update to upstream version v1.6.1-66-gabbd523bae6e This adds the following commits from upstream: abbd523bae6e pylibfdt: Work-around SWIG limitations with flexible arrays a41509bea3e7 libfdt: Replace deprecated 0-length arrays with proper flexible arrays 2cd89f862cdb dtc: Warning rather than error on possible truncation of cell values Reviewed-by: Kees Cook Link: https://lore.kernel.org/all/20230203172430.474431-1-robh@kernel.org/ Signed-off-by: Rob Herring --- scripts/dtc/dtc-parser.y | 11 ++++++++--- scripts/dtc/libfdt/fdt.h | 4 ++-- scripts/dtc/version_gen.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/dtc/dtc-parser.y b/scripts/dtc/dtc-parser.y index 46457d4bc0aa..bff1337ec266 100644 --- a/scripts/dtc/dtc-parser.y +++ b/scripts/dtc/dtc-parser.y @@ -404,9 +404,14 @@ arrayprefix: * within the mask to one (i.e. | in the * mask), all bits are one. */ - if (($2 > mask) && (($2 | mask) != -1ULL)) - ERROR(&@2, "Value out of range for" - " %d-bit array element", $1.bits); + if (($2 > mask) && (($2 | mask) != -1ULL)) { + char *loc = srcpos_string(&@2); + fprintf(stderr, + "WARNING: %s: Value 0x%016" PRIx64 + " truncated to 0x%0*" PRIx64 "\n", + loc, $2, $1.bits / 4, ($2 & mask)); + free(loc); + } } $$.data = data_append_integer($1.data, $2, $1.bits); diff --git a/scripts/dtc/libfdt/fdt.h b/scripts/dtc/libfdt/fdt.h index f2e68807f277..0c91aa7f67b5 100644 --- a/scripts/dtc/libfdt/fdt.h +++ b/scripts/dtc/libfdt/fdt.h @@ -35,14 +35,14 @@ struct fdt_reserve_entry { struct fdt_node_header { fdt32_t tag; - char name[0]; + char name[]; }; struct fdt_property { fdt32_t tag; fdt32_t len; fdt32_t nameoff; - char data[0]; + char data[]; }; #endif /* !__ASSEMBLY */ diff --git a/scripts/dtc/version_gen.h b/scripts/dtc/version_gen.h index 0f303087b043..99614ec1a289 100644 --- a/scripts/dtc/version_gen.h +++ b/scripts/dtc/version_gen.h @@ -1 +1 @@ -#define DTC_VERSION "DTC 1.6.1-g55778a03" +#define DTC_VERSION "DTC 1.6.1-gabbd523b" -- cgit v1.2.3-58-ga151 From 511f3aa71029ef4d9408065f94110c0e8f9dccba Mon Sep 17 00:00:00 2001 From: Frank Rowand Date: Mon, 13 Feb 2023 12:56:56 -0600 Subject: of: prepare to add processing of EXPECT_NOT to of_unittest_expect scripts/dtc/of_unittest_expect processes EXPECT messages that document expected kernel messages triggered by unittest. Add processing of EXPECT_NOT messages that document kernel messages triggered by unittest that are not expected. This is commit 1 of 2, renaming existing variables in anticipation of the changes needed to process EXPECT_NOT, so that commit 2 of 2 will be smaller and easier to read. This commit is not intended to make any functional changes. Signed-off-by: Frank Rowand Link: https://lore.kernel.org/r/20230213185702.395776-2-frowand.list@gmail.com Signed-off-by: Rob Herring --- scripts/dtc/of_unittest_expect | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/dtc/of_unittest_expect b/scripts/dtc/of_unittest_expect index 96b12d9ea606..7b25bb693162 100755 --- a/scripts/dtc/of_unittest_expect +++ b/scripts/dtc/of_unittest_expect @@ -9,7 +9,7 @@ # on the console log that results from executing the Linux kernel # devicetree unittest (drivers/of/unitest.c). -$VUFX = "220201a"; +$VUFX = "230121a"; use strict 'refs'; use strict subs; @@ -274,7 +274,7 @@ while ($line = ) { if ($line =~ /^\s*$exp_begin/) { $data = $line; $data =~ s/^\s*$exp_begin//; - push @begin, $data; + push @exp_begin_stack, $data; if ($verbose) { if ($print_line_num) { @@ -302,20 +302,20 @@ while ($line = ) { $found = 0; $no_begin = 0; - if (@found_or_begin > 0) { - $begin = pop @found_or_begin; + if (@exp_found_or_begin > 0) { + $begin = pop @exp_found_or_begin; if (compare($data, $begin)) { $found = 1; } } elsif (@begin > 0) { - $begin = pop @begin; + $begin = pop @exp_begin_stack; } else { $no_begin = 1; } if ($no_begin) { - $expect_missing_begin++; + $exp_missing_begin++; print "** ERROR: EXPECT end without any EXPECT begin:\n"; print " end ---> $line\n"; @@ -325,20 +325,20 @@ while ($line = ) { $line_num = sprintf("%4s ", $.); } - $expect_not_found++; + $exp_missing++; printf "** %s%s$script_name WARNING - not found ---> %s\n", $line_num, $timestamp, $data; } elsif (! compare($data, $begin)) { - $expect_missing_end++; + $exp_missing_end++; print "** ERROR: EXPECT end does not match EXPECT begin:\n"; print " begin -> $begin\n"; print " end ---> $line\n"; } else { - $expect_found++; + $exp_found++; } @@ -357,7 +357,7 @@ while ($line = ) { } $found = 0; - foreach $begin (@begin) { + foreach $begin (@exp_begin_stack) { if (compare($begin, $line)) { $found = 1; last; @@ -365,12 +365,12 @@ while ($line = ) { } if ($found) { - $begin = shift @begin; + $begin = shift @exp_begin_stack; while (! compare($begin, $line)) { - push @found_or_begin, $begin; - $begin = shift @begin; + push @exp_found_or_begin, $begin; + $begin = shift @exp_begin_stack; } - push @found_or_begin, $line; + push @exp_found_or_begin, $line; if ($hide_expect) { $suppress_line = 1; @@ -391,18 +391,18 @@ if (! $no_expect_stats) { print "\n"; print "** EXPECT statistics:\n"; print "**\n"; - printf "** EXPECT found : %4i\n", $expect_found; - printf "** EXPECT not found : %4i\n", $expect_not_found; - printf "** missing EXPECT begin : %4i\n", $expect_missing_begin; - printf "** missing EXPECT end : %4i\n", $expect_missing_end; + printf "** EXPECT found : %4i\n", $exp_found; + printf "** EXPECT not found : %4i\n", $exp_missing; + printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; + printf "** missing EXPECT end : %4i\n", $exp_missing_end; printf "** unittest FAIL : %4i\n", $unittest_fail; printf "** internal error : %4i\n", $internal_err; } -if (@begin) { +if (@exp_begin_stack) { print "** ERROR: EXPECT begin without any EXPECT end:\n"; print " This list may be misleading.\n"; - foreach $begin (@begin) { + foreach $begin (@exp_begin_stack) { print " begin ---> $begin\n"; } } -- cgit v1.2.3-58-ga151 From 568a10bfffe88daa42f1b7968352cc6abd948ca3 Mon Sep 17 00:00:00 2001 From: Frank Rowand Date: Mon, 13 Feb 2023 12:56:57 -0600 Subject: of: add processing of EXPECT_NOT to of_unittest_expect scripts/dtc/of_unittest_expect processes EXPECT messages that document expected kernel messages triggered by unittest. Add processing of EXPECT_NOT messages that document kernel messages triggered by unittest that are not expected. This is commit 2 of 2, implementing the processing of EXPECT_NOT messages. Signed-off-by: Frank Rowand Link: https://lore.kernel.org/r/20230213185702.395776-3-frowand.list@gmail.com Signed-off-by: Rob Herring --- scripts/dtc/of_unittest_expect | 157 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 145 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/dtc/of_unittest_expect b/scripts/dtc/of_unittest_expect index 7b25bb693162..0a535a8e9821 100755 --- a/scripts/dtc/of_unittest_expect +++ b/scripts/dtc/of_unittest_expect @@ -9,7 +9,7 @@ # on the console log that results from executing the Linux kernel # devicetree unittest (drivers/of/unitest.c). -$VUFX = "230121a"; +$VUFX = "230211a"; use strict 'refs'; use strict subs; @@ -62,6 +62,8 @@ sub compare { } else { return 0; } + } elsif ($type eq "all") { + return 1; } elsif ($type eq "") { if ($expect_next ne $got_next) { return 0; @@ -130,6 +132,7 @@ usage: <> matches: [+-]*[0-9]+ <> matches: (0x)*[0-9a-f]+ + <> matches: anything to end of line 'EXPECT \\' (begin) and 'EXPECT /' (end) lines are suppressed. @@ -240,6 +243,8 @@ if ($#ARGV != 0) { $pr_fmt = "### dt-test ### "; $exp_begin = "${pr_fmt}EXPECT \\\\ : "; $exp_end = "${pr_fmt}EXPECT / : "; +$expnot_begin = "${pr_fmt}EXPECT_NOT \\\\ : "; +$expnot_end = "${pr_fmt}EXPECT_NOT / : "; $line_num = ""; @@ -250,6 +255,8 @@ while ($line = ) { chomp $line; + $suppress_line = 0; + $prefix = " "; ## 2 characters @@ -306,6 +313,7 @@ while ($line = ) { $begin = pop @exp_found_or_begin; if (compare($data, $begin)) { $found = 1; + $exp_found++; } } elsif (@begin > 0) { $begin = pop @exp_begin_stack; @@ -316,7 +324,7 @@ while ($line = ) { if ($no_begin) { $exp_missing_begin++; - print "** ERROR: EXPECT end without any EXPECT begin:\n"; + print "** ERROR: EXPECT end without matching EXPECT begin:\n"; print " end ---> $line\n"; } elsif (! $found) { @@ -329,17 +337,97 @@ while ($line = ) { printf "** %s%s$script_name WARNING - not found ---> %s\n", $line_num, $timestamp, $data; - } elsif (! compare($data, $begin)) { + } elsif (! compare($data, $begin) and ($data ne $begin)) { $exp_missing_end++; print "** ERROR: EXPECT end does not match EXPECT begin:\n"; print " begin -> $begin\n"; print " end ---> $line\n"; + } + + next LINE; + } + + + # ----- find EXPECT_NOT begin + + if ($line =~ /^\s*$expnot_begin/) { + $data = $line; + $data =~ s/^\s*$expnot_begin//; + push @expnot_begin_stack, $data; + + if ($verbose) { + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; + } + + next LINE; + } + + + # ----- find EXPECT_NOT end + + if ($line =~ /^\s*$expnot_end/) { + $data = $line; + $data =~ s/^\s*$expnot_end//; + + if ($verbose) { + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + printf "%s %s%s%s\n", $prefix, $line_num, $timestamp, $line; + } + + $found = 0; + $no_begin = 0; + if (@expnot_found_or_begin > 0) { + $begin = pop @expnot_found_or_begin; + if (compare($data, $begin)) { + $found = 1; + $expnot_found++; + } + } elsif (@expnot_begin_stack <= 0) { + $no_begin = 1; + } + + if ($no_begin) { + + $expnot_missing_begin++; + print "** ERROR: EXPECT_NOT end without matching EXPECT_NOT begin:\n"; + print " end ---> $line\n"; + + } + + if ($found) { + + if ($print_line_num) { + $line_num = sprintf("%4s ", $.); + } + + printf "** %s%s$script_name WARNING - next line matches EXPECT_NOT\n", + $line_num, $timestamp; + printf "** %s%s%s\n", $line_num, $timestamp, $line; + } else { - $exp_found++; + $expnot_missing++; + + } + + if (@expnot_begin_stack > 0) { + $begin = pop @expnot_begin_stack; + + if (! compare($data, $begin) and ($data ne $begin)) { + $expnot_missing_end++; + print "** ERROR: EXPECT_NOT end does not match EXPECT_NOT begin:\n"; + print " begin -> $begin\n"; + print " end ---> $line\n"; + + } } next LINE; @@ -374,12 +462,38 @@ while ($line = ) { if ($hide_expect) { $suppress_line = 1; - next LINE; } $prefix = "ok"; # 2 characters } + $found = 0; + foreach $begin (@expnot_begin_stack) { + if (compare($begin, $line)) { + $found = 1; + last; + } + } + + if ($found) { + $begin = shift @begin; + while (! compare($begin, $line)) { + push @expnot_found_or_begin, $begin; + $begin = shift @begin; + } + push @expnot_found_or_begin, $line; + + if ($hide_expect) { + $suppress_line = 1; + } + $prefix = "**"; # 2 characters + } + + + if ($suppress_line) { + next LINE; + } + if ($print_line_num) { $line_num = sprintf("%4s ", $.); } @@ -391,18 +505,37 @@ if (! $no_expect_stats) { print "\n"; print "** EXPECT statistics:\n"; print "**\n"; - printf "** EXPECT found : %4i\n", $exp_found; - printf "** EXPECT not found : %4i\n", $exp_missing; - printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; - printf "** missing EXPECT end : %4i\n", $exp_missing_end; - printf "** unittest FAIL : %4i\n", $unittest_fail; - printf "** internal error : %4i\n", $internal_err; + printf "** non-zero values expected:\n"; + print "**\n"; + printf "** EXPECT found : %4i\n", $exp_found; + printf "** EXPECT_NOT not found : %4i\n", $expnot_missing; + print "**\n"; + printf "** zero values expected:\n"; + print "**\n"; + printf "** EXPECT not found : %4i\n", $exp_missing; + printf "** missing EXPECT begin : %4i\n", $exp_missing_begin; + printf "** missing EXPECT end : %4i\n", $exp_missing_end; + print "**\n"; + printf "** EXPECT_NOT found : %4i\n", $expnot_found; + printf "** missing EXPECT_NOT begin : %4i\n", $expnot_missing_begin; + printf "** missing EXPECT_NOT end : %4i\n", $expnot_missing_end; + print "**\n"; + printf "** unittest FAIL : %4i\n", $unittest_fail; + printf "** internal error : %4i\n", $internal_err; } if (@exp_begin_stack) { - print "** ERROR: EXPECT begin without any EXPECT end:\n"; + print "** ERROR: EXPECT begin without matching EXPECT end:\n"; print " This list may be misleading.\n"; foreach $begin (@exp_begin_stack) { print " begin ---> $begin\n"; } } + +if (@expnot_begin_stack) { + print "** ERROR: EXPECT_NOT begin without matching EXPECT_NOT end:\n"; + print " This list may be misleading.\n"; + foreach $begin (@expnot_begin_stack) { + print " begin ---> $begin\n"; + } +} -- cgit v1.2.3-58-ga151