src/dpdk/lib/librte_ethdev/rte_flow.c
static int
rte_flow_conv_rule(struct rte_flow_conv_rule *dst,
		   const size_t size,
		   const struct rte_flow_conv_rule *src,
		   struct rte_flow_error *error)
{
	size_t off;
	int ret;

	rte_memcpy(dst,
		   (&(struct rte_flow_conv_rule){
			.attr = NULL,
			.pattern = NULL,
			.actions = NULL,
		   }),
		   size > sizeof(*dst) ? sizeof(*dst) : size);
	off = sizeof(*dst);
	if (src->attr_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		if (size && size >= off + sizeof(*dst->attr))
			dst->attr = rte_memcpy
				((void *)((uintptr_t)dst + off),
				 src->attr_ro, sizeof(*dst->attr));
		off += sizeof(*dst->attr);
	}
	if (src->pattern_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		ret = rte_flow_conv_pattern((void *)((uintptr_t)dst + off),
					    size > off ? size - off : 0,
					    src->pattern_ro, 0, error);
		if (ret < 0)
			return ret;
		if (size && size >= off + (size_t)ret)
			dst->pattern = (void *)((uintptr_t)dst + off);
		off += ret;
	}
	if (src->actions_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		ret = rte_flow_conv_actions((void *)((uintptr_t)dst + off),
					    size > off ? size - off : 0,
					    src->actions_ro, 0, error);
		if (ret < 0)
			return ret;
		if (size >= off + (size_t)ret)
			dst->actions = (void *)((uintptr_t)dst + off);
		off += ret;
	}
	return off;
}
/**
 * Copy flow rule components.
 *
 * This comprises the flow rule descriptor itself, attributes, pattern and
 * actions list. NULL components in @p src are skipped.
 *
 * @param[out] dst
 *   Destination buffer. Can be NULL if @p size is zero.
 * @param size
 *   Size of @p dst in bytes.
 * @param[in] src
 *   Source flow rule descriptor.
 * @param[out] error
 *   Perform verbose error reporting if not NULL.
 *
 * @return
 *   A positive value representing the number of bytes needed to store all
 *   components including the descriptor regardless of @p size on success
 *   (@p buf contents are truncated to @p size if not large enough), a
 *   negative errno value otherwise and rte_errno is set.
 */
Copy flow rule components.
This comprises the flow rule descriptor itself, attributes, pattern and
actions list. NULL components in @p src are skipped.

@param[out] dst
Destination buffer. Can be NULL if @p size is zero.
@param size
Size of @p dst in bytes.
@param[in] src
Source flow rule descriptor.
@param[out] error
Perform verbose error reporting if not NULL.

@return
A positive value representing the number of bytes needed to store all
components including the descriptor regardless of @p size on success
(@p buf contents are truncated to @p size if not large enough), a
negative errno value otherwise and rte_errno is set.
Copy flow rule components . This comprises the flow rule descriptor itself attributes pattern and actions list . NULL components in @p src are skipped . @param [ out ] dst Destination buffer . Can be NULL if @p size is zero . @param size Size of @p dst in bytes . @param [ in ] src Source flow rule descriptor . @param [ out ] error Perform verbose error reporting if not NULL . @return A positive value representing the number of bytes needed to store all components including the descriptor regardless of @p size on success ( @p buf contents are truncated to @p size if not large enough ) a negative errno value otherwise and rte_errno is set .
static int
rte_flow_conv_rule(struct rte_flow_conv_rule *dst,
		   const size_t size,
		   const struct rte_flow_conv_rule *src,
		   struct rte_flow_error *error)
{
	size_t off;
	int ret;
	rte_memcpy(dst,
		   (&(struct rte_flow_conv_rule){
			.attr = NULL,
			.pattern = NULL,
			.actions = NULL,
		   }),
		   size > sizeof(*dst) ? sizeof(*dst) : size);
	off = sizeof(*dst);
	if (src->attr_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		if (size && size >= off + sizeof(*dst->attr))
			dst->attr = rte_memcpy
				((void *)((uintptr_t)dst + off),
				 src->attr_ro, sizeof(*dst->attr));
		off += sizeof(*dst->attr);
	}
	if (src->pattern_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		ret = rte_flow_conv_pattern((void *)((uintptr_t)dst + off),
					    size > off ? size - off : 0,
					    src->pattern_ro, 0, error);
		if (ret < 0)
			return ret;
		if (size && size >= off + (size_t)ret)
			dst->pattern = (void *)((uintptr_t)dst + off);
		off += ret;
	}
	if (src->actions_ro) {
		off = RTE_ALIGN_CEIL(off, sizeof(double));
		ret = rte_flow_conv_actions((void *)((uintptr_t)dst + off),
					    size > off ? size - off : 0,
					    src->actions_ro, 0, error);
		if (ret < 0)
			return ret;
		if (size >= off + (size_t)ret)
			dst->actions = (void *)((uintptr_t)dst + off);
		off += ret;
	}
	return off;
}
static int rte_flow_conv_rule ( struct rte_flow_conv_rule * dst , const size_t size , const struct rte_flow_conv_rule * src , struct rte_flow_error * error ) { size_t off ; int ret ; rte_memcpy ( dst , ( & ( struct rte_flow_conv_rule ) { . attr = NULL , . pattern = NULL , . actions = NULL , } ) , size > sizeof ( * dst ) ? sizeof ( * dst ) : size ) ; off = sizeof ( * dst ) ; if ( src -> attr_ro ) { off = RTE_ALIGN_CEIL ( off , sizeof ( double ) ) ; if ( size && size >= off + sizeof ( * dst -> attr ) ) dst -> attr = rte_memcpy ( ( void * ) ( ( uintptr_t ) dst + off ) , src -> attr_ro , sizeof ( * dst -> attr ) ) ; off += sizeof ( * dst -> attr ) ; } if ( src -> pattern_ro ) { off = RTE_ALIGN_CEIL ( off , sizeof ( double ) ) ; ret = rte_flow_conv_pattern ( ( void * ) ( ( uintptr_t ) dst + off ) , size > off ? size - off : 0 , src -> pattern_ro , 0 , error ) ; if ( ret < 0 ) return ret ; if ( size && size >= off + ( size_t ) ret ) dst -> pattern = ( void * ) ( ( uintptr_t ) dst + off ) ; off += ret ; } if ( src -> actions_ro ) { off = RTE_ALIGN_CEIL ( off , sizeof ( double ) ) ; ret = rte_flow_conv_actions ( ( void * ) ( ( uintptr_t ) dst + off ) , size > off ? size - off : 0 , src -> actions_ro , 0 , error ) ; if ( ret < 0 ) return ret ; if ( size >= off + ( size_t ) ret ) dst -> actions = ( void * ) ( ( uintptr_t ) dst + off ) ; off += ret ; } return off ; }
Copy flow rule components.
Copy flow rule components .