diff options
author | Anthony G. Basile <blueness@gentoo.org> | 2013-07-07 11:07:06 -0400 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2013-07-07 11:16:55 -0400 |
commit | faa1ff8ef8d98fe148ac0efab15fcdf0cabdcaae (patch) | |
tree | 4f0816897494168e1d0bab25367fb5b6782aaaa4 /src/collect/collect.c | |
parent | 44e6f1bc1a3f11daf569d310de1707f3b423786a (diff) |
Import strxcpyx from upstream
This commit imports strxcpyx from upstream. This is upstream commit
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3d
Note: there were also some very minor code cleanups to
accelerometer.c: line 187
collect.c: lines 35, 140
libudev-device.c: line 780
libudev-hwdb.c: line 300
These are part of upstream commits:
507f22bd0172bff5e5d98145b1419bd472a2c57f
3cf7b686e6b29f78de0af5929602cae4482f6d49
67410e9f73a6cdd8453c78b966451b5151def14a
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/collect/collect.c')
-rw-r--r-- | src/collect/collect.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/collect/collect.c b/src/collect/collect.c index 3dd702dfab..834e27683c 100644 --- a/src/collect/collect.c +++ b/src/collect/collect.c @@ -35,8 +35,8 @@ #include "libudev-private.h" #include "macro.h" -#define BUFSIZE 16 -#define UDEV_ALARM_TIMEOUT 180 +#define BUFSIZE 16 +#define UDEV_ALARM_TIMEOUT 180 enum collect_state { STATE_NONE, @@ -140,12 +140,14 @@ static int checkout(int fd) restart: len = bufsize >> 1; - buf = calloc(1,bufsize + 1); + buf = malloc(bufsize + 1); if (!buf) { fprintf(stderr, "Out of memory.\n"); return log_oom(); } memset(buf, ' ', bufsize); + buf[bufsize] = '\0'; + ptr = buf + len; while ((read(fd, buf + len, len)) > 0) { while (ptr && *ptr) { @@ -214,7 +216,7 @@ static void invite(char *us) udev_list_node_foreach(him_node, &bunch) { struct _mate *him = node_to_mate(him_node); - if (!strcmp(him->name, us)) { + if (streq(him->name, us)) { him->state = STATE_CONFIRMED; who = him; } @@ -242,7 +244,7 @@ static void reject(char *us) udev_list_node_foreach(him_node, &bunch) { struct _mate *him = node_to_mate(him_node); - if (!strcmp(him->name, us)) { + if (streq(him->name, us)) { him->state = STATE_NONE; who = him; } @@ -415,7 +417,7 @@ int main(int argc, char **argv) if (debug) fprintf(stderr, "Using checkpoint '%s'\n", checkpoint); - util_strscpyl(tmpdir, sizeof(tmpdir), "/run/udev/collect", NULL); + strscpyl(tmpdir, sizeof(tmpdir), "/run/udev/collect", NULL); fd = prepare(tmpdir, checkpoint); if (fd < 0) { ret = 3; @@ -435,7 +437,7 @@ int main(int argc, char **argv) udev_list_node_foreach(him_node, &bunch) { struct _mate *him = node_to_mate(him_node); - if (!strcmp(him->name, argv[i])) + if (streq(him->name, argv[i])) who = him; } if (!who) { |