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 ca1a83dd47617910320f4d7393b765f774a88a57..37d17f5839e2ebb4047a4f338e6634be44c9b2e8 100644
(file)
--- a/
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
+++ b/
formats/ctf/metadata/ctf-visitor-generate-io-struct.c
@@
-25,6
+25,7
@@
#include <inttypes.h>
#include <endian.h>
#include <errno.h>
#include <inttypes.h>
#include <endian.h>
#include <errno.h>
+#include <babeltrace/babeltrace.h>
#include <babeltrace/list.h>
#include <babeltrace/types.h>
#include <babeltrace/ctf/metadata.h>
#include <babeltrace/list.h>
#include <babeltrace/types.h>
#include <babeltrace/ctf/metadata.h>
@@
-124,7
+125,7
@@
int get_unary_uuid(struct cds_list_head *head, uuid_t *uuid)
}
static
}
static
-struct ctf_stream *trace_stream_lookup(struct ctf_trace *trace, uint64_t stream_id)
+struct ctf_stream
_class
*trace_stream_lookup(struct ctf_trace *trace, uint64_t stream_id)
{
if (trace->streams->len <= stream_id)
return NULL;
{
if (trace->streams->len <= stream_id)
return NULL;
@@
-1087,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",
@@
-1155,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",
@@
-1514,7
+1527,7
@@
error:
static
static
-int ctf_stream_declaration_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_stream *stream, struct ctf_trace *trace)
+int ctf_stream_declaration_visit(FILE *fd, int depth, struct ctf_node *node, struct ctf_stream
_class
*stream, struct ctf_trace *trace)
{
int ret = 0;
{
int ret = 0;
@@
-1636,10
+1649,10
@@
int ctf_stream_visit(FILE *fd, int depth, struct ctf_node *node,
{
int ret = 0;
struct ctf_node *iter;
{
int ret = 0;
struct ctf_node *iter;
- struct ctf_stream *stream;
+ struct ctf_stream
_class
*stream;
struct definition_scope *parent_def_scope;
struct definition_scope *parent_def_scope;
- stream = g_new0(struct ctf_stream, 1);
+ stream = g_new0(struct ctf_stream
_class
, 1);
stream->declaration_scope = new_declaration_scope(parent_declaration_scope);
stream->events_by_id = g_ptr_array_new();
stream->event_quark_to_id = g_hash_table_new(g_direct_hash, g_direct_equal);
stream->declaration_scope = new_declaration_scope(parent_declaration_scope);
stream->events_by_id = g_ptr_array_new();
stream->event_quark_to_id = g_hash_table_new(g_direct_hash, g_direct_equal);
@@
-1963,7
+1976,7
@@
int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
int ret = 0;
struct ctf_node *iter;
int ret = 0;
struct ctf_node *iter;
-
fprintf(fd,
"CTF visitor: metadata construction... ");
+
printf_verbose(
"CTF visitor: metadata construction... ");
trace->root_declaration_scope = new_declaration_scope(NULL);
trace->byte_order = byte_order;
trace->root_declaration_scope = new_declaration_scope(NULL);
trace->byte_order = byte_order;
@@
-2011,6
+2024,6
@@
int ctf_visitor_construct_metadata(FILE *fd, int depth, struct ctf_node *node,
(int) node->type);
return -EINVAL;
}
(int) node->type);
return -EINVAL;
}
-
fprintf(fd,
"done.\n");
+
printf_verbose(
"done.\n");
return ret;
}
return ret;
}
This page took
0.025191 seconds
and
4
git commands to generate.