priv-kweihmann / oelint-adv

Advanced oelint
BSD 2-Clause "Simplified" License
53 stars 27 forks source link

__main__.py: Improve status report through exit codes #590

Closed mario-goulart closed 1 month ago

mario-goulart commented 1 month ago

Always exit non-zero when issues are encountered.

In case the number of issues was 256 or its multiples, the executable would exit 0 as values greater than 255 overflow the range of valid exit codes (0..255). Example:

$ python -c 'import sys; sys.exit(256)'; echo $?
0

In case of issues identified in bitbake metadata, hardcode the exit code to 1. Ideally the exit code should encode the type of issues identified, for example, using the convention assumed by pylint (https://pylint.pycqa.org/en/v3.2.3/user_guide/usage/run.html#exit-codes), but this is not done in this change, as it requires identifying the type of changes in the object returned by the run function.

Also, make the code exit according to the valid range for exit codes and adhere to the conventions in /usr/include/sysexits.h, namely

  #define EX_SOFTWARE     70      /* internal software error */

for internal software error.

os.EX_SOFTWARE has not been explicitly used because it might not be supported by platforms other than Unix. Its value (70) has been used instead, since we have to use an arbitrary non-zero value in the valid exit code range anyway.

Signed-off-by: Mario Domenech Goulart Mario.Goulart@bmw.de