{
struct lldpd_pi *pi;
char *hex;
+ int i;
TAILQ_FOREACH(pi, &port->p_pids, p_entries) {
if (!pi->p_pi_len) continue;
tag_start(w, "pi", "PI");
/* Convert to hex for display */
if ((hex = malloc(pi->p_pi_len * 2 + 1)) == NULL)
fatal(NULL);
- for (int i = 0; i < pi->p_pi_len; i++)
+ for (i = 0; i < pi->p_pi_len; i++)
snprintf(hex + 2*i, 3, "%02X", (unsigned char)pi->p_pi[i]);
tag_data(w, hex);
tag_end(w);
struct marshal_info marshal_info_string = {
.name = "null string",
.size = 0,
- .pointers = {{ .mi = NULL }},
+ .pointers = {MARSHAL_SUBINFO_NULL},
};
struct marshal_info marshal_info_fstring = {
.name = "fixed string",
.size = 0,
- .pointers = {{ .mi = NULL }},
+ .pointers = {MARSHAL_SUBINFO_NULL},
};
struct marshal_info marshal_info_ignore = {
.name = "ignored",
.size = 0,
- .pointers = {{ .mi = NULL }},
+ .pointers = {MARSHAL_SUBINFO_NULL},
};
/* List of already seen pointers */
enum marshal_subinfo_kind kind; /* Kind of substructure */
struct marshal_info *mi;
};
+#define MARSHAL_SUBINFO_NULL { .offset = 0, .offset2 = 0, .kind = ignore, .mi = NULL }
struct marshal_info {
char *name; /* Name of structure */
size_t size; /* Size of the structure */
+#if defined __GNUC__ && __GNUC__ < 3
+ /* With gcc 2.96, flexible arrays are not supported, even with
+ * -std=gnu99. And with gcc 3.x, zero-sized arrays cannot be statically
+ * initialized (with more than one element). */
+ struct marshal_subinfo pointers[0]; /* Pointer to other structures */
+#else
struct marshal_subinfo pointers[]; /* Pointer to other structures */
+#endif
};
/* Special case for strings */
extern struct marshal_info marshal_info_string;
.pointers = {
#define MARSHAL_ADD(_kind, type, subtype, member) \
{ .offset = offsetof(struct type, member), \
+ .offset2 = 0, \
.kind = _kind, \
.mi = &MARSHAL_INFO(subtype) },
#define MARSHAL_FSTR(type, member, len) \
.offset2 = offsetof(struct type, len), \
.kind = pointer, \
.mi = &marshal_info_fstring },
-#define MARSHAL_END { .mi = NULL } } }
+#define MARSHAL_END MARSHAL_SUBINFO_NULL }}
#else
#define MARSHAL_BEGIN(type) extern struct marshal_info MARSHAL_INFO(type)
#define MARSHAL_ADD(...)