From: Arran Cudbard-Bell Date: Fri, 14 Jul 2017 19:13:21 +0000 (-0400) Subject: Remove boxing for size_t, conflicts with uint64 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d235b9d4cb15bc0782ee43ba40764c2acc16dafc;p=thirdparty%2Ffreeradius-server.git Remove boxing for size_t, conflicts with uint64 --- diff --git a/src/include/value.h b/src/include/value.h index 5f5584f465c..f6944e5cc34 100644 --- a/src/include/value.h +++ b/src/include/value.h @@ -298,8 +298,6 @@ FR_VALUE_BOX(uint64_t, date_milliseconds, FR_TYPE_DATE_MILLISECONDS) FR_VALUE_BOX(uint64_t, date_microseconds, FR_TYPE_DATE_MICROSECONDS) FR_VALUE_BOX(uint64_t, date_nanoseconds, FR_TYPE_DATE_NANOSECONDS) -FR_VALUE_BOX(size_t, size, FR_TYPE_SIZE) - /** Automagically fill in a box, determining the value type from the type of the C variable * * Simplify boxing for simple C types using the _Generic macro to emit code that @@ -326,8 +324,7 @@ _Generic((_var), \ int32_t : fr_value_box_int32, \ int64_t : fr_value_box_int64, \ float : fr_value_box_float32, \ - double : fr_value_box_float64, \ - size_t : fr_value_box_size \ + double : fr_value_box_float64 \ )(_box, NULL, _var, _tainted) /** Unbox an ethernet value (6 bytes, network byte order) @@ -380,8 +377,6 @@ FR_VALUE_UNBOX(uint64_t, date_milliseconds, FR_TYPE_DATE_MILLISECONDS) FR_VALUE_UNBOX(uint64_t, date_microseconds, FR_TYPE_DATE_MICROSECONDS) FR_VALUE_UNBOX(uint64_t, date_nanoseconds, FR_TYPE_DATE_NANOSECONDS) -FR_VALUE_UNBOX(size_t, size, FR_TYPE_SIZE) - /** Unbox simple types peforming type checks * * @param[out] _var to write to. @@ -398,8 +393,7 @@ _Generic((_var), \ int32_t * : fr_value_unbox_int32, \ int64_t * : fr_value_unbox_int64, \ float * : fr_value_unbox_float32, \ - double * : fr_value_unbox_float64, \ - size_t * : fr_value_unbox_size \ + double * : fr_value_unbox_float64 \ )(_var, _box) /* @} **/ diff --git a/src/lib/io/proto.h b/src/lib/io/proto.h index 18dafde45ad..3890ef015ea 100644 --- a/src/lib/io/proto.h +++ b/src/lib/io/proto.h @@ -131,18 +131,19 @@ typedef void (*fr_proto_invert_t)(void *proto_ctx); * * @param[in] out boxed value containing the option. * @param[in] proto_ctx to retrieve data from. - * @param[in] group Option group to use. + * @param[in] opt_group Option group to use. * @param[in] opt to retrieve. * @return * - 0 on success. * - -1 on failure. */ -typedef int (*fr_proto_get_option_t)(fr_value_box_t *out, void const *proto_ctx, fr_proto_opt_group_t group, int opt); +typedef int (*fr_proto_get_option_t)(fr_value_box_t *out, void const *proto_ctx, + fr_proto_opt_group_t opt_group, int opt); /** Set a protocol option * * @param[in] proto_ctx to set option in. - * @param[in] group Option group to use. + * @param[in] opt_group Option group to use. * @param[in] opt to set. * @param[in] in value to set. * @return @@ -158,7 +159,7 @@ typedef int (*fr_proto_set_option_t)(void *proto_ctx, fr_proto_opt_group_t opt_g typedef struct { RAD_MODULE_COMMON; //!< Common fields to all loadable modules. - size_t proto_ctx_size; //!< Size required for the packet ctx structure. + size_t proto_ctx_size; //!< Size required for the packet ctx structure. fr_proto_opt_group_t opt_group; //!< Option groups implemented by proto lib. diff --git a/src/protocols/ethernet/ethernet.c b/src/protocols/ethernet/ethernet.c index a5978dd526c..79c0517c7f8 100644 --- a/src/protocols/ethernet/ethernet.c +++ b/src/protocols/ethernet/ethernet.c @@ -297,7 +297,9 @@ static int fr_ethernet_get_option(fr_value_box_t *out, void const *proto_ctx, fr case PROTO_OPT_GROUP_L2: switch (opt) { case PROTO_OPT_L2_PAYLOAD_LEN: - return fr_value_box_shallow(out, ether_ctx->payload_len, true); + fr_value_box_init(out, FR_TYPE_SIZE, NULL, true); + out->vb_size = ether_ctx->payload_len; + return 0; case PROTO_OPT_L2_SRC_ADDRESS: return fr_value_box_ethernet_addr(out, NULL, ether_ctx->src_addr, true); @@ -370,7 +372,14 @@ static int fr_ethernet_set_option(void *proto_ctx, fr_proto_opt_group_t group, i case PROTO_OPT_GROUP_L2: switch (opt) { case PROTO_OPT_L2_PAYLOAD_LEN: - return fr_value_unbox_shallow(ðer_ctx->payload_len, in); + if (in->type != FR_TYPE_SIZE) { + fr_strerror_printf("Unboxing failed. Needed type %s, had type %s", + fr_int2str(dict_attr_types, FR_TYPE_SIZE, "?Unknown?"), + fr_int2str(dict_attr_types, in->type, "?Unknown?")); + return -1; + } + ether_ctx->payload_len = in->vb_size; + return 0; case PROTO_OPT_L2_SRC_ADDRESS: return fr_value_unbox_ethernet_addr(ether_ctx->src_addr, in);