projects
/
babeltrace.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add alignment power of two check
[babeltrace.git]
/
formats
/
ctf
/
metadata
/
ctf-visitor-generate-io-struct.c
diff --git
a/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
b/formats/ctf/metadata/ctf-visitor-generate-io-struct.c
index 9da7d0d8322d8aecd55590db613de4bdab2388d2..37d17f5839e2ebb4047a4f338e6634be44c9b2e8 100644
(file)
--- a/
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
+++ b/
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
@@
-1088,6
+1088,12
@@
struct declaration *ctf_declaration_integer_visit(FILE *fd, int depth,
return NULL;
}
alignment = right->u.unary_expression.u.unsigned_constant;
return NULL;
}
alignment = right->u.unary_expression.u.unsigned_constant;
+ /* Make sure alignment is a power of two */
+ if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
+ fprintf(fd, "[error] %s: align: expecting power of two\n",
+ __func__);
+ return NULL;
+ }
has_alignment = 1;
} else {
fprintf(fd, "[error] %s: unknown attribute name %s\n",
has_alignment = 1;
} else {
fprintf(fd, "[error] %s: unknown attribute name %s\n",
@@
-1156,6
+1162,12
@@
struct declaration *ctf_declaration_floating_point_visit(FILE *fd, int depth,
return NULL;
}
alignment = right->u.unary_expression.u.unsigned_constant;
return NULL;
}
alignment = right->u.unary_expression.u.unsigned_constant;
+ /* Make sure alignment is a power of two */
+ if (alignment == 0 || (alignment & (alignment - 1)) != 0) {
+ fprintf(fd, "[error] %s: align: expecting power of two\n",
+ __func__);
+ return NULL;
+ }
has_alignment = 1;
} else {
fprintf(fd, "[error] %s: unknown attribute name %s\n",
has_alignment = 1;
} else {
fprintf(fd, "[error] %s: unknown attribute name %s\n",
This page took
0.02292 seconds
and
4
git commands to generate.