[Buildroot] [PATCH 1/4] utils/check-package: cleanup line reading
Thomas Petazzoni
thomas.petazzoni at bootlin.com
Sat Aug 26 20:09:09 UTC 2023
Hello James,
On Sat, 29 Apr 2023 14:12:02 -0400
James Knight <james.d.knight at live.com> wrote:
> Cleanup the implementation for reading lines by having files processed
> in context managers and utilizing the iterable file object for line
> reading (instead of needing to call `readlines()`).
>
> Signed-off-by: James Knight <james.d.knight at live.com>
> ---
> utils/check-package | 22 ++++++++++++----------
> 1 file changed, 12 insertions(+), 10 deletions(-)
>
> diff --git a/utils/check-package b/utils/check-package
> index 83b9750f5a9c181dc96dcba508682776a600aac5..db3a00b524bc2c2aa663d3621c94fb11a6db7cb3 100755
> --- a/utils/check-package
> +++ b/utils/check-package
> @@ -229,16 +229,18 @@ def check_file_using_lib(fname):
> nwarnings += warn
>
> lastline = ""
> - for lineno, text in enumerate(open(fname, "r", errors="surrogateescape").readlines()):
> - nlines += 1
> - for name, cf in objects:
> - if cf.disable.search(lastline):
> - continue
> - warn, fail = print_warnings(cf.check_line(lineno + 1, text), name in xfail)
> - if fail > 0:
> - failed.add(name)
> - nwarnings += warn
> - lastline = text
> + with open(fname, "r", errors="surrogateescape") as f:
> + for lineno, text in enumerate(f):
> + nlines += 1
> + for name, cf in objects:
> + if cf.disable.search(lastline):
> + continue
> + line_sts = cf.check_line(fstate, lineno + 1, text)
This variable "fstate" doesn't exist as of PATCH 1/4. I wanted to apply
only this patch for now, as I'm not sure about PATCH 2/4 to PATCH 4/4,
but PATCH 1/4 on its own doesn't work. Could you have a look?
Thanks!
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
More information about the buildroot
mailing list