scripts: python: cleanup script and fix PEP8 issues
Ran scripts through flake8 and fixed issues.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/scripts/gen_syscall_header.py b/scripts/gen_syscall_header.py
index 627b8a1..6eab116 100755
--- a/scripts/gen_syscall_header.py
+++ b/scripts/gen_syscall_header.py
@@ -7,11 +7,13 @@
import sys
from enum import Enum
+
class Retval(Enum):
VOID = 0
U32 = 1
U64 = 2
+
def gen_macro(ret, argc):
if ret == Retval.VOID:
suffix = "_VOID"
@@ -27,12 +29,13 @@
sys.stdout.write(", t%d, p%d" % (i, i))
sys.stdout.write(")")
+
def gen_fn(ret, argc, name, extern=False):
sys.stdout.write("\t%s %s %s(" %
- (("extern" if extern else "static inline"),
- ("ret" if ret != Retval.VOID else "void"), name))
+ (("extern" if extern else "static inline"),
+ ("ret" if ret != Retval.VOID else "void"), name))
if argc == 0:
- sys.stdout.write("void");
+ sys.stdout.write("void")
else:
for i in range(argc):
sys.stdout.write("t%d p%d" % (i, i))
@@ -40,8 +43,10 @@
sys.stdout.write(", ")
sys.stdout.write(")")
+
def tabs(count):
- sys.stdout.write("\t" * count);
+ sys.stdout.write("\t" * count)
+
def gen_make_syscall(ret, argc, tabcount):
tabs(tabcount)
@@ -64,18 +69,20 @@
# dropped, and the hndlr_ref section is itself dropped from the binary
# from gc-sections; these references will not consume space.
- sys.stdout.write("static _GENERIC_SECTION(hndlr_ref) __used void *href = (void *)&_handler_##name; \\\n")
+ sys.stdout.write(
+ "static _GENERIC_SECTION(hndlr_ref) __used void *href = (void *)&_handler_##name; \\\n")
tabs(tabcount)
if (ret != Retval.VOID):
sys.stdout.write("return (ret)")
if (argc <= 6 and ret != Retval.U64):
sys.stdout.write("_arch")
sys.stdout.write("_syscall%s_invoke%d(" %
- (("_ret64" if ret == Retval.U64 else ""), argc))
+ (("_ret64" if ret == Retval.U64 else ""), argc))
for i in range(argc):
sys.stdout.write("(u32_t)p%d, " % (i))
sys.stdout.write("id); \\\n")
+
def gen_call_impl(ret, argc):
if (ret != Retval.VOID):
sys.stdout.write("return ")
@@ -86,9 +93,11 @@
sys.stdout.write(", ")
sys.stdout.write("); \\\n")
+
def newline():
sys.stdout.write(" \\\n")
+
def gen_defines_inner(ret, argc, kernel_only=False, user_only=False):
sys.stdout.write("#define ")
gen_macro(ret, argc)
@@ -99,7 +108,7 @@
sys.stdout.write(";")
newline()
- gen_fn(ret, argc, "name");
+ gen_fn(ret, argc, "name")
newline()
sys.stdout.write("\t{")
newline()
@@ -120,7 +129,7 @@
# Prevent memory access issues if the implementation function gets
# inlined
- sys.stdout.write("\t\t\tcompiler_barrier();");
+ sys.stdout.write("\t\t\tcompiler_barrier();")
newline()
sys.stdout.write("\t\t\t")
@@ -137,11 +146,13 @@
gen_defines_inner(Retval.U64, argc, kernel_only, user_only)
-sys.stdout.write("/* Auto-generated by gen_syscall_header.py, do not edit! */\n\n")
+sys.stdout.write(
+ "/* Auto-generated by gen_syscall_header.py, do not edit! */\n\n")
sys.stdout.write("#ifndef GEN_SYSCALL_H\n#define GEN_SYSCALL_H\n\n")
for i in range(11):
- sys.stdout.write("#if !defined(CONFIG_USERSPACE) || defined(__ZEPHYR_SUPERVISOR__)\n")
+ sys.stdout.write(
+ "#if !defined(CONFIG_USERSPACE) || defined(__ZEPHYR_SUPERVISOR__)\n")
gen_defines(i, kernel_only=True)
sys.stdout.write("#elif defined(__ZEPHYR_USER__)\n")
gen_defines(i, user_only=True)
@@ -150,8 +161,3 @@
sys.stdout.write("#endif /* mixed kernel/user macros */\n\n")
sys.stdout.write("#endif /* GEN_SYSCALL_H */\n")
-
-
-
-
-