summaryrefslogtreecommitdiff
path: root/src/collect
diff options
context:
space:
mode:
authorlhb-jr <lhb.jr@gmx.com>2014-03-21 11:55:36 -0400
committerlhb-jr <lhb.jr@gmx.com>2014-03-21 11:55:36 -0400
commit728baddb472075e21421ebdc5de0a6e992453fbc (patch)
tree5b40ec262cb7dc5953ae761ef00f46eca72d641a /src/collect
parentc0acbd0656ae0aeaa53f1d291fdee385ea43f7ff (diff)
fixed gcc warnings that call returns not checked
modified: src/collect/collect.c modified: src/udev/udev-node.c modified: src/udev/udevadm-settle.c modified: src/udev/udevd.c
Diffstat (limited to 'src/collect')
-rw-r--r--src/collect/collect.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/src/collect/collect.c b/src/collect/collect.c
index 7fefc62c10..b99a170420 100644
--- a/src/collect/collect.c
+++ b/src/collect/collect.c
@@ -83,6 +83,8 @@ static void usage(void)
* prepare
*
* Prepares the database file
+ * returns file descriptor on success
+ * returns errno on failure
*/
static int prepare(char *dir, char *filename)
{
@@ -96,21 +98,22 @@ static int prepare(char *dir, char *filename)
snprintf(buf, sizeof(buf), "%s/%s", dir, filename);
fd = open(buf,O_RDWR|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
- if (fd < 0)
+ if (fd < 0) {
fprintf(stderr, "Cannot open %s: %m\n", buf);
-
+ return errno;
+ }
if (lockf(fd,F_TLOCK,0) < 0) {
if (debug)
- fprintf(stderr, "Lock taken, wait for %d seconds\n", UDEV_ALARM_TIMEOUT);
- if (errno == EAGAIN || errno == EACCES) {
- alarm(UDEV_ALARM_TIMEOUT);
- lockf(fd, F_LOCK, 0);
- if (debug)
- fprintf(stderr, "Acquired lock on %s\n", buf);
- } else {
+ fprintf(stderr, "Lock aquisition failed, retry in %d seconds\n"
+ , UDEV_ALARM_TIMEOUT);
+ alarm(UDEV_ALARM_TIMEOUT);
+ if(lockf(fd, F_LOCK, 0)<0){
if (debug)
fprintf(stderr, "Could not get lock on %s: %m\n", buf);
- }
+ return errno;
+ }
+ if (debug)
+ fprintf(stderr, "Acquired lock on %s\n", buf);
}
return fd;
@@ -476,10 +479,16 @@ int main(int argc, char **argv)
kickout();
lseek(fd, 0, SEEK_SET);
- ftruncate(fd, 0);
+ if(ftruncate(fd, 0)!=0) {
+ ret = errno;
+ goto out;
+ }
ret = missing(fd);
- lockf(fd, F_ULOCK, 0);
+ if(lockf(fd, F_ULOCK, 0) !=0 ) {
+ ret = errno;
+ goto out;
+ }
close(fd);
out:
if (debug)