summaryrefslogtreecommitdiffstats
path: root/cpukit/libnetworking/rtems/rtems_glue.c
diff options
context:
space:
mode:
authorThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-10-10 15:56:32 +0000
committerThomas Doerfler <Thomas.Doerfler@embedded-brains.de>2008-10-10 15:56:32 +0000
commit06c3530efcc3cd4230278e150a0b828359982ca0 (patch)
tree580801d390e34d1ead99dcea1c06520539002306 /cpukit/libnetworking/rtems/rtems_glue.c
parent Update for status-checks.h changes. (diff)
downloadrtems-06c3530efcc3cd4230278e150a0b828359982ca0.tar.bz2
libnetworking/rtems/rtems_glue.c: Copy nothing if rtems_bsdnet_parse_driver_name() if namep is NULL.
include/rtems/status-checks.h: Added prefix "RTEMS" for all macros. Doxygen style comments. Cleanup.
Diffstat (limited to 'cpukit/libnetworking/rtems/rtems_glue.c')
-rw-r--r--cpukit/libnetworking/rtems/rtems_glue.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c
index 07e70e5c39..d3d589c166 100644
--- a/cpukit/libnetworking/rtems/rtems_glue.c
+++ b/cpukit/libnetworking/rtems/rtems_glue.c
@@ -1148,8 +1148,14 @@ int rtems_bsdnet_ifconfig(const char *ifname, uint32_t cmd, void *param)
return r;
}
-/*
- * Parse a network driver name into a name and a unit number
+/**
+ * @brief Splits a network interface name with interface configuration @a
+ * config into the unit name and number parts.
+ *
+ * Memory for the unit name will be allocated from the heap and copied to @a
+ * namep. If @a namep is NULL nothing will be allocated and copied.
+ *
+ * Returns the unit number or -1 on error.
*/
int
rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char **namep)
@@ -1171,14 +1177,16 @@ rtems_bsdnet_parse_driver_name (const struct rtems_bsdnet_ifconfig *config, char
unitNumber = (unitNumber * 10) + (c - '0');
c = *cp++;
if (c == '\0') {
- char *unitName = malloc (len);
- if (unitName == NULL) {
- printf ("No memory.\n");
- return -1;
+ if (namep != NULL) {
+ char *unitName = malloc (len);
+ if (unitName == NULL) {
+ printf ("No memory.\n");
+ return -1;
+ }
+ strncpy (unitName, config->name, len - 1);
+ unitName[len-1] = '\0';
+ *namep = unitName;
}
- strncpy (unitName, config->name, len - 1);
- unitName[len-1] = '\0';
- *namep = unitName;
return unitNumber;
}
if ((c < '0') || (c > '9'))