From 3b9f21c6c3f06fd5049aa43f116906417d92e11f Mon Sep 17 00:00:00 2001 From: Alice Frosi Date: Mon, 5 Jun 2023 16:54:12 +0200 Subject: cooker: use unsigned short for family with connect --- cooker/call.c | 2 ++ cooker/calls/net.c | 2 +- cooker/cooker.h | 3 ++- cooker/emit.c | 3 ++- cooker/gluten.c | 1 + cooker/match.c | 1 + 6 files changed, 9 insertions(+), 3 deletions(-) (limited to 'cooker') diff --git a/cooker/call.c b/cooker/call.c index d44ff6f..1c29db8 100644 --- a/cooker/call.c +++ b/cooker/call.c @@ -139,6 +139,7 @@ static union value parse_field(struct gluten_ctx *g, struct arg *args, return v; switch (f->type) { + case USHORT: case INT: case LONG: case U32: @@ -245,6 +246,7 @@ bool arg_needs_temp(struct field *f, int pos, JSON_Value *jvalue, } switch (f->type) { + case USHORT: case INT: case LONG: case U32: diff --git a/cooker/calls/net.c b/cooker/calls/net.c index 7231a0e..7a7fd33 100644 --- a/cooker/calls/net.c +++ b/cooker/calls/net.c @@ -162,7 +162,7 @@ static struct field connect_addr_nl[] = { }; static struct field connect_family = { - "family", INT, 0, + "family", USHORT, 0, offsetof(struct sockaddr, sa_family), 0, { .d_num = af } }; diff --git a/cooker/cooker.h b/cooker/cooker.h index 40277c2..7a14221 100644 --- a/cooker/cooker.h +++ b/cooker/cooker.h @@ -64,6 +64,7 @@ enum type { UNDEF = 0, NONE, + USHORT, INT, U32, U64, @@ -107,7 +108,7 @@ enum flags { #define TYPE_IS_COMPOUND(t) \ ((t) == STRUCT || (t) == SELECT) #define TYPE_IS_NUM(t) \ - ((t) == INT || (t) == U32 || (t) == U64 || (t) == LONG) + ((t) == INT || (t) == U32 || (t) == U64 || (t) == LONG || (t) == USHORT) /** * struct num - A numeric value and its label diff --git a/cooker/emit.c b/cooker/emit.c index 4303115..4be5d35 100644 --- a/cooker/emit.c +++ b/cooker/emit.c @@ -16,7 +16,7 @@ static const char *type_str[] = { "UNDEF", "NONE", - "INT", "U32", "U64", "LONG", + "USHORT", "INT", "U32", "U64", "LONG", "STRING", "STRUCT", "SELECT", "PID", @@ -331,6 +331,7 @@ static struct gluten_offset emit_data_do(struct gluten_ctx *g, } switch (type) { + case USHORT: case INT: if (add) { *(int *)p |= value->v_int; diff --git a/cooker/gluten.c b/cooker/gluten.c index 01c2369..cb9ecfb 100644 --- a/cooker/gluten.c +++ b/cooker/gluten.c @@ -13,6 +13,7 @@ #include "util.h" size_t gluten_size[TYPE_COUNT] = { + [USHORT] = sizeof(unsigned short), [INT] = sizeof(int), [U32] = sizeof(uint32_t), [U64] = sizeof(uint64_t), diff --git a/cooker/match.c b/cooker/match.c index 593cd55..c53a456 100644 --- a/cooker/match.c +++ b/cooker/match.c @@ -103,6 +103,7 @@ static union value parse_field(struct gluten_ctx *g, offset.offset += f->offset; switch (f->type) { + case USHORT: case INT: case LONG: case U32: -- cgit v1.2.3