Skip to contentSkip to conversation

Drop unneeded system header includes

PATCH In review Eric Blake 3 participants 3 messages Feb 7, 2018

lore
Share & tools
lore

Eric Blake

author
#0 lore raw

PATCH 1/1 Drop unneeded system header includes

<memory.h> is a non-standard obsolete header that was long ago replaced by <string.h>.

<malloc.h> is a non-standard header; it is not obsolete (we must use it for malloc_trim, for example), but generally should not be used in files that just need malloc() and friends, where <stdlib.h> is the standard header.

And since osdep.h already guarantees string.h and stdlib.h, we can drop these unusual system header includes as redundant rather than replacing them.

---

Based-on: <[email protected]> ([PULL 00/20] Miscellaneous patches for 2018-02-07)

 target/i386/hax-windows.h | 2 --
 target/i386/hvf/x86_mmu.c | 1 -
 2 files changed, 3 deletions(-)
target/i386/hax-windows.h +0 -2
index 004f8676949..20e2f85407b 100644
@@ -20,8 +20,6 @@
 #ifndef TARGET_I386_HAX_WINDOWS_H
 #define TARGET_I386_HAX_WINDOWS_H
 
-#include <memory.h>
-#include <malloc.h>
 #include <winioctl.h>
 #include <windef.h>
 
target/i386/hvf/x86_mmu.c +0 -1
index c6be2cca357..d5a0efe7188 100644
@@ -17,7 +17,6 @@
  */
 
 #include "qemu/osdep.h"
-#include <memory.h>
 #include "panic.h"
 #include "qemu-common.h"
 #include "cpu.h"
Signature · 1 line
2.14.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Eric Blake

<memory.h> is a non-standard obsolete header that was long ago replaced by <string.h>.

<malloc.h> is a non-standard header; it is not obsolete (we must use it for malloc_trim, for example), but generally should not be used in files that just need malloc() and friends, where <stdlib.h> is the standard header.

Quoted 5 lines

And since osdep.h already guarantees string.h and stdlib.h, we can drop these unusual system header includes as redundant rather than replacing them.

Quoted 35 lines

---

Based-on: <[email protected]> ([PULL 00/20] Miscellaneous patches for 2018-02-07)

 target/i386/hax-windows.h | 2 --
 target/i386/hvf/x86_mmu.c | 1 -
 2 files changed, 3 deletions(-)
target/i386/hax-windows.h +0 -2
index 004f8676949..20e2f85407b 100644
@@ -20,8 +20,6 @@
 #ifndef TARGET_I386_HAX_WINDOWS_H
 #define TARGET_I386_HAX_WINDOWS_H
 
-#include <memory.h>
-#include <malloc.h>
 #include <winioctl.h>
 #include <windef.h>
 
target/i386/hvf/x86_mmu.c +0 -1
index c6be2cca357..d5a0efe7188 100644
@@ -17,7 +17,6 @@
  */
 
 #include "qemu/osdep.h"
-#include <memory.h>
 #include "panic.h"
 #include "qemu-common.h"
 #include "cpu.h"
Reviewed-by on v1 1/1
#2 lore raw
In reply to Eric Blake
Quoted 13 lines · Eric Blake

<memory.h> is a non-standard obsolete header that was long ago replaced by <string.h>.

<malloc.h> is a non-standard header; it is not obsolete (we must use it for malloc_trim, for example), but generally should not be used in files that just need malloc() and friends, where <stdlib.h> is the standard header.

And since osdep.h already guarantees string.h and stdlib.h, we can drop these unusual system header includes as redundant rather than replacing them.

Quoted 8 lines

---

Based-on: <[email protected]> ([PULL 00/20] Miscellaneous patches for 2018-02-07)

 target/i386/hax-windows.h | 2 --
 target/i386/hvf/x86_mmu.c | 1 -
 2 files changed, 3 deletions(-)