OSDN Git Service

tools: ynl-gen: add extra headers for user space
authorJakub Kicinski <kuba@kernel.org>
Fri, 2 Jun 2023 02:35:39 +0000 (19:35 -0700)
committerJakub Kicinski <kuba@kernel.org>
Sat, 3 Jun 2023 05:10:46 +0000 (22:10 -0700)
Make sure all relevant headers are included, we allocate memory,
use memcpy() and Linux types without including the headers.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/ynl-gen-c.py

index be66451..5823ddf 100755 (executable)
@@ -2103,6 +2103,13 @@ def main():
             cw.nl()
         headers = ['uapi/' + parsed.uapi_header]
     else:
+        cw.p('#include <stdlib.h>')
+        if args.header:
+            cw.p('#include <string.h>')
+            cw.p('#include <linux/types.h>')
+        else:
+            cw.p(f'#include "{parsed.name}-user.h"')
+            cw.p('#include "ynl.h"')
         headers = [parsed.uapi_header]
     for definition in parsed['definitions']:
         if 'header' in definition: