Skip to content
Snippets Groups Projects
Commit c0451f0b authored by Christian Schoenebeck's avatar Christian Schoenebeck
Browse files

fsdev/p9array.h: check scalar type in P9ARRAY_NEW()


Make sure at compile time that the scalar type of the array
requested to be created via P9ARRAY_NEW() matches the scalar
type of the passed auto reference variable (unique pointer).

Suggested-by: default avatarRichard Henderson <richard.henderson@linaro.org>
Signed-off-by: default avatarChristian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <c1965e2a096835dc9e1d4d659dfb15d96755cbe0.1633097129.git.qemu_oss@crudebyte.com>
parent 30e702ab
No related branches found
No related tags found
No related merge requests found
......@@ -27,6 +27,8 @@
#ifndef QEMU_P9ARRAY_H
#define QEMU_P9ARRAY_H
#include "qemu/compiler.h"
/**
* P9Array provides a mechanism to access arrays in common C-style (e.g. by
* square bracket [] operator) in conjunction with reference variables that
......@@ -149,6 +151,10 @@
* @param len - amount of array elements to be allocated immediately
*/
#define P9ARRAY_NEW(scalar_type, auto_var, len) \
QEMU_BUILD_BUG_MSG( \
!__builtin_types_compatible_p(scalar_type, typeof(*auto_var)), \
"P9Array scalar type mismatch" \
); \
p9array_new_##scalar_type((&auto_var), len)
#endif /* QEMU_P9ARRAY_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment