summaryrefslogtreecommitdiff
path: root/namedev.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-03-09 19:50:15 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:35:08 -0700
commit17794d77b97fcb8af263bcecbe03dad5d0e9a89a (patch)
treefc87f4d731a6543aaae346875768ff57fc85413a /namedev.c
parent3f20eac0a58dc3987200773a39163e30b60993fc (diff)
[PATCH] rename strn*() macros to strmax
Hey, I wrote the strn*() macros just 10 days ago and yesterday this trap caught me with the %c{x} bug. The names are misleading cause we all expect that the from field is limited by the size argument, but we actually limit the overall size of the destination string to prevent a overflow. Here we rename all strn*() macros to str*max(). That should be more self-explanatory.
Diffstat (limited to 'namedev.c')
-rw-r--r--namedev.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/namedev.c b/namedev.c
index dfeadee18a..23d46518ea 100644
--- a/namedev.c
+++ b/namedev.c
@@ -247,27 +247,27 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
case 'b':
if (strlen(udev->bus_id) == 0)
break;
- strnfieldcat(string, udev->bus_id, maxsize);
+ strfieldcatmax(string, udev->bus_id, maxsize);
dbg("substitute bus_id '%s'", udev->bus_id);
break;
case 'k':
if (strlen(udev->kernel_name) == 0)
break;
- strnfieldcat(string, udev->kernel_name, maxsize);
+ strfieldcatmax(string, udev->kernel_name, maxsize);
dbg("substitute kernel name '%s'", udev->kernel_name);
break;
case 'n':
if (strlen(udev->kernel_number) == 0)
break;
- strnfieldcat(string, udev->kernel_number, maxsize);
+ strfieldcatmax(string, udev->kernel_number, maxsize);
dbg("substitute kernel number '%s'", udev->kernel_number);
break;
case 'm':
- strnintcat(string, udev->minor, maxsize);
+ strintcatmax(string, udev->minor, maxsize);
dbg("substitute minor number '%u'", udev->minor);
break;
case 'M':
- strnintcat(string, udev->major, maxsize);
+ strintcatmax(string, udev->major, maxsize);
dbg("substitute major number '%u'", udev->major);
break;
case 'c':
@@ -287,11 +287,11 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
dbg("requested part of result string not found");
break;
}
- strnfieldcpy(temp2, spos, slen+1);
- strnfieldcat(string, temp2, maxsize);
+ strfieldcpymax(temp2, spos, slen+1);
+ strfieldcatmax(string, temp2, maxsize);
dbg("substitute part of result string '%s'", temp2);
} else {
- strnfieldcat(string, udev->program_result, maxsize);
+ strfieldcatmax(string, udev->program_result, maxsize);
dbg("substitute result string '%s'", udev->program_result);
}
break;
@@ -302,14 +302,14 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
dbg("sysfa attribute '%s' not found", attr);
break;
}
- strnfieldcat(string, tmpattr->value, maxsize);
+ strfieldcatmax(string, tmpattr->value, maxsize);
dbg("substitute sysfs value '%s'", tmpattr->value);
} else {
dbg("missing attribute");
}
break;
case '%':
- strnfieldcat(string, "%", maxsize);
+ strfieldcatmax(string, "%", maxsize);
break;
default:
dbg("unknown substitution type '%%%c'", c);
@@ -319,7 +319,7 @@ static void apply_format(struct udevice *udev, char *string, size_t maxsize,
if (len > 0)
pos[len] = '\0';
- strnfieldcat(string, tail, maxsize);
+ strfieldcatmax(string, tail, maxsize);
}
}
@@ -428,7 +428,7 @@ static int execute_program(char *path, char *value, int len)
dup(fds[1]);
/* copy off our path to use incase we have too many args */
- strnfieldcpy(buffer, path, sizeof(buffer));
+ strfieldcpymax(buffer, path, sizeof(buffer));
if (strchr(path, ' ')) {
/* exec with arguments */