Also, make sure to start the actual text at the margin.
=======================================================
+* eal: ``rte_strscpy`` sets ``rte_errno`` to ``E2BIG`` in case of string
+ truncation.
+
ABI Changes
-----------
#include <errno.h>
#include <rte_string_fns.h>
+#include <rte_errno.h>
/* split string into tokens */
int
/* Not enough room in dst, set NUL and return error. */
if (res != 0)
dst[res - 1] = '\0';
- return -E2BIG;
+ rte_errno = E2BIG;
+ return -rte_errno;
}
/* Initialize the trace point */
if (rte_strscpy(tp->name, name, TRACE_POINT_NAME_SIZE) < 0) {
trace_err("name is too long");
- rte_errno = E2BIG;
goto free;
}
* Copy string src to buffer dst of size dsize.
* At most dsize-1 chars will be copied.
* Always NUL-terminates, unless (dsize == 0).
- * Returns number of bytes copied (terminating NUL-byte excluded) on success ;
- * negative errno on error.
*
* @param dst
* The destination string.
* Length in bytes of the destination buffer.
*
* @return
- * The number of bytes copied on success
+ * The number of bytes copied (terminating NUL-byte excluded) on success.
* -E2BIG if the destination buffer is too small.
+ * rte_errno is set.
*/
ssize_t
rte_strscpy(char *dst, const char *src, size_t dsize);
}
/* Initialize the node */
- if (rte_strscpy(node->name, reg->name, RTE_NODE_NAMESIZE) < 0) {
- rte_errno = E2BIG;
+ if (rte_strscpy(node->name, reg->name, RTE_NODE_NAMESIZE) < 0)
goto free;
- }
node->flags = reg->flags;
node->process = reg->process;
node->init = reg->init;
node->parent_id = reg->parent_id;
for (i = 0; i < reg->nb_edges; i++) {
if (rte_strscpy(node->next_nodes[i], reg->next_nodes[i],
- RTE_NODE_NAMESIZE) < 0) {
- rte_errno = E2BIG;
+ RTE_NODE_NAMESIZE) < 0)
goto free;
- }
}
node->id = node_id++;
/* Update the new nodes name */
for (i = from; i < max_edges; i++, count++) {
if (rte_strscpy(node->next_nodes[i], next_nodes[count],
- RTE_NODE_NAMESIZE) < 0) {
- rte_errno = E2BIG;
+ RTE_NODE_NAMESIZE) < 0)
goto restore;
- }
}
restore:
/* Update the linked list to point new node address in prev node */