summaryrefslogtreecommitdiff
path: root/extras
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2009-05-20 17:57:52 +0200
committerKay Sievers <kay.sievers@vrfy.org>2009-05-20 17:57:52 +0200
commit065db052211d3bf08d9b0f698a79a8798faf11d2 (patch)
tree970ac911636e2711c99ab050a7fd341e95ea08a9 /extras
parentf58a9099bb2b18f3f683615324a4382b95446305 (diff)
use more efficient string copying
Diffstat (limited to 'extras')
-rw-r--r--extras/edd_id/edd_id.c2
-rw-r--r--extras/fstab_import/fstab_import.c4
-rw-r--r--extras/scsi_id/scsi_id.c8
-rw-r--r--extras/usb_id/usb_id.c28
4 files changed, 19 insertions, 23 deletions
diff --git a/extras/edd_id/edd_id.c b/extras/edd_id/edd_id.c
index 4154387cb6..9e9667fc62 100644
--- a/extras/edd_id/edd_id.c
+++ b/extras/edd_id/edd_id.c
@@ -157,7 +157,7 @@ int main(int argc, char *argv[])
if (disk_id == sysfs_id) {
if (match[0] == '\0') {
/* store id */
- util_strlcpy(match, dent->d_name, sizeof(match));
+ util_strscpy(match, sizeof(match), dent->d_name);
} else {
/* error, same signature for another device */
info(udev, "'%s' does not have a unique signature\n", node);
diff --git a/extras/fstab_import/fstab_import.c b/extras/fstab_import/fstab_import.c
index e793604faa..e46ba7ec44 100644
--- a/extras/fstab_import/fstab_import.c
+++ b/extras/fstab_import/fstab_import.c
@@ -144,7 +144,7 @@ int main(int argc, char *argv[])
if (label[0] == '"' || label[0] == '\'') {
char *pos;
- util_strlcpy(str, &label[1], sizeof(str));
+ util_strscpy(str, sizeof(str), &label[1]);
pos = strrchr(str, label[0]);
if (pos == NULL)
continue;
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
if (uuid[0] == '"' || uuid[0] == '\'') {
char *pos;
- util_strlcpy(str, &uuid[1], sizeof(str));
+ util_strscpy(str, sizeof(str), &uuid[1]);
pos = strrchr(str, uuid[0]);
if (pos == NULL)
continue;
diff --git a/extras/scsi_id/scsi_id.c b/extras/scsi_id/scsi_id.c
index d630cf902b..213a267afa 100644
--- a/extras/scsi_id/scsi_id.c
+++ b/extras/scsi_id/scsi_id.c
@@ -105,7 +105,7 @@ static void set_type(const char *from, char *to, size_t len)
break;
}
}
- util_strlcpy(to, type, len);
+ util_strscpy(to, len, type);
}
/*
@@ -354,7 +354,7 @@ static int set_options(struct udev *udev,
case 'd':
dev_specified = 1;
- util_strlcpy(maj_min_dev, optarg, MAX_PATH_LEN);
+ util_strscpy(maj_min_dev, MAX_PATH_LEN, optarg);
break;
case 'e':
@@ -362,7 +362,7 @@ static int set_options(struct udev *udev,
break;
case 'f':
- util_strlcpy(config_file, optarg, MAX_PATH_LEN);
+ util_strscpy(config_file, MAX_PATH_LEN, optarg);
break;
case 'g':
@@ -428,7 +428,7 @@ static int set_options(struct udev *udev,
}
if (optind < argc && !dev_specified) {
dev_specified = 1;
- util_strlcpy(maj_min_dev, argv[optind], MAX_PATH_LEN);
+ util_strscpy(maj_min_dev, MAX_PATH_LEN, argv[optind]);
}
return 0;
}
diff --git a/extras/usb_id/usb_id.c b/extras/usb_id/usb_id.c
index 36477669c5..4679f94fde 100644
--- a/extras/usb_id/usb_id.c
+++ b/extras/usb_id/usb_id.c
@@ -134,7 +134,7 @@ static int set_usb_mass_storage_ifsubtype(char *to, const char *from, size_t len
break;
}
}
- util_strlcpy(to, type, len);
+ util_strscpy(to, len, type);
return type_num;
}
@@ -166,7 +166,7 @@ static void set_scsi_type(char *to, const char *from, size_t len)
break;
}
}
- util_strlcpy(to, type, len);
+ util_strscpy(to, len, type);
}
#define USB_DT_DEVICE 0x01
@@ -509,8 +509,7 @@ int main(int argc, char **argv)
goto exit;
}
- util_strlcpy(syspath, udev_get_sys_path(udev), sizeof(syspath));
- util_strlcat(syspath, devpath, sizeof(syspath));
+ util_strscpyl(syspath, sizeof(syspath), udev_get_sys_path(udev), devpath, NULL);
dev = udev_device_new_from_syspath(udev, syspath);
if (dev == NULL) {
err(udev, "unable to access '%s'\n", devpath);
@@ -520,18 +519,15 @@ int main(int argc, char **argv)
retval = usb_id(dev);
if (retval == 0) {
char serial[256];
-
- util_strlcpy(serial, vendor_str, sizeof(serial));
- util_strlcat(serial, "_", sizeof(serial));
- util_strlcat(serial, model_str, sizeof(serial));
- if (serial_str[0] != '\0') {
- util_strlcat(serial, "_", sizeof(serial));
- util_strlcat(serial, serial_str, sizeof(serial));
- }
- if (instance_str[0] != '\0') {
- util_strlcat(serial, "-", sizeof(serial));
- util_strlcat(serial, instance_str, sizeof(serial));
- }
+ size_t l;
+ char *s;
+
+ s = serial;
+ l = util_strpcpyl(&s, sizeof(serial), vendor_str, "_", model_str, NULL);
+ if (serial_str[0] != '\0')
+ l = util_strpcpyl(&s, l, "_", serial_str, NULL);
+ if (instance_str[0] != '\0')
+ util_strpcpyl(&s, l, "-", instance_str, NULL);
if (export) {
printf("ID_VENDOR=%s\n", vendor_str);