[PATCH v3 11/81] buildman: Warn about dangling maintainer entries

Simon Glass sjg at chromium.org
Sun Jul 16 02:35:39 CEST 2023


Other than the top-level MAINTAINERS file, all maintainer entries should
actually reference a target. Add a warning to detect those that do not.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

Changes in v3:
- Add new patch to warn about dangling maintainer entries

 tools/buildman/boards.py    | 21 ++++++++++++++++-----
 tools/buildman/func_test.py |  9 ++++++---
 2 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/tools/buildman/boards.py b/tools/buildman/boards.py
index df57f278daad..a606ce27aef7 100644
--- a/tools/buildman/boards.py
+++ b/tools/buildman/boards.py
@@ -345,17 +345,28 @@ class MaintainersDatabase:
             srcdir (str): Directory containing source code (Kconfig files)
             fname (str): MAINTAINERS file to be parsed
         """
-        def add_targets():
-            """Add any new targets"""
+        def add_targets(linenum):
+            """Add any new targets
+
+            Args:
+                linenum (int): Current line number
+            """
+            added = False
             if targets:
                 for target in targets:
                     self.database[target] = (status, maintainers)
+                    added = True
+            if not added and (status != '-' and maintainers):
+                leaf = fname[len(srcdir) + 1:]
+                if leaf != 'MAINTAINERS':
+                    self.warnings.append(
+                        f'WARNING: {leaf}: missing defconfig ending at line {linenum + 1}')
 
         targets = []
         maintainers = []
         status = '-'
         with open(fname, encoding="utf-8") as inf:
-            for line in inf:
+            for linenum, line in enumerate(inf):
                 # Check also commented maintainers
                 if line[:3] == '#M:':
                     line = line[1:]
@@ -388,11 +399,11 @@ class MaintainersDatabase:
                                 if match and not rear:
                                     targets.append(front)
                 elif line == '\n':
-                    add_targets()
+                    add_targets(linenum)
                     targets = []
                     maintainers = []
                     status = '-'
-        add_targets()
+        add_targets(linenum)
 
 
 class Boards:
diff --git a/tools/buildman/func_test.py b/tools/buildman/func_test.py
index 43087b4e08d2..73abe16e1ca5 100644
--- a/tools/buildman/func_test.py
+++ b/tools/buildman/func_test.py
@@ -917,7 +917,8 @@ Active  aarch64     armv8 - armltd total_compute board2
         params_list, warnings = self._boards.build_board_list(config_dir, src)
         self.assertEquals(2, len(params_list))
         self.assertEquals(
-            ["WARNING: no status info for 'board0'",
+            ['WARNING: boards/board0/MAINTAINERS: missing defconfig ending at line 4',
+             "WARNING: no status info for 'board0'",
              "WARNING: no maintainers for 'board0'"], warnings)
 
         # Remove the maintainer line (M:) from a file (this should be fine)
@@ -937,9 +938,11 @@ Active  aarch64     armv8 - armltd total_compute board2
         self.assertEquals(2, len(params_list))
         self.assertFalse(warnings)
 
-        # Add another record, this should be ignored
+        # Add another record, this should be ignored with a warning
         extra = '\n\nAnother\nM: Fred\nF: configs/board9_defconfig\nS: other\n'
         tools.write_file(main, data + extra, binary=False)
         params_list, warnings = self._boards.build_board_list(config_dir, src)
         self.assertEquals(2, len(params_list))
-        self.assertFalse(warnings)
+        self.assertEquals(
+            ['WARNING: boards/board0/MAINTAINERS: missing defconfig ending at line 16'],
+             warnings)
-- 
2.41.0.455.g037347b96a-goog



More information about the U-Boot mailing list