Skip to content

Commit 85e58cb

Browse files
berrangeJiri Denemark
authored andcommitted
add missing includes for C library functions
We use various C library functions like printf, strcmp, free but don't have the corresponding #includes, getting them indirectly via Python.h. This is a bad idea as Python.h is not guaranteed to provided these, and indeed will omit them when Py_LIMITED_API is greater then 0x030a0000. Signed-off-by: Daniel P. Berrangé <[email protected]>
1 parent c4ede87 commit 85e58cb

File tree

5 files changed

+9
-0
lines changed

5 files changed

+9
-0
lines changed

generator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@ def emit_c_code(module: str) -> None:
881881

882882
wrapper = open(wrapper_file, "w")
883883
wrapper.write("/* Generated by generator.py */\n\n")
884+
wrapper.write("#include <stdlib.h>\n")
884885
wrapper.write("#include <Python.h>\n")
885886
wrapper.write("#include <libvirt/%s.h>\n" % (module,))
886887
wrapper.write("#include \"typewrappers.h\"\n")

libvirt-override.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
#define VIR_ENUM_SENTINELS
1919

2020
#define PY_SSIZE_T_CLEAN
21+
22+
#include <stdio.h>
23+
#include <string.h>
2124
#include <Python.h>
2225
#include <libvirt/libvirt.h>
2326
#include <libvirt/virterror.h>

libvirt-qemu-override.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
1515
#undef HAVE_PTHREAD_H
1616

17+
#include <stdio.h>
1718
#include <Python.h>
1819
#include <libvirt/libvirt-qemu.h>
1920
#include <libvirt/virterror.h>

libvirt-utils.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
*
2020
*/
2121

22+
#include <string.h>
23+
2224
#include <Python.h>
2325

2426
/* Ugly python defines that, which is also defined in errno.h */

typewrappers.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
* which has over 180 autoconf-style HAVE_* definitions. Shame on them. */
1313
#undef HAVE_PTHREAD_H
1414

15+
#include <stdio.h>
16+
#include <string.h>
1517
#include "typewrappers.h"
1618
#include "libvirt-utils.h"
1719

0 commit comments

Comments
 (0)