Be more verbose

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2018-05-09 15:27:57 +00:00
parent 0cce48e9fd
commit 5c532b2e56
4 changed files with 34 additions and 11 deletions

View File

@@ -153,8 +153,8 @@ ctl_connect(const char *dir, const char *file)
continue; continue;
if (file) { if (file) {
file = NULL; closedir(dp);
break; return -3;
} }
file = &d->d_name[0]; file = &d->d_name[0];
@@ -162,8 +162,7 @@ ctl_connect(const char *dir, const char *file)
if (!file) { if (!file) {
closedir(dp); closedir(dp);
errno = ENOENT; return -2;
return -1;
} }
} }

View File

@@ -99,9 +99,20 @@ gt_path(int argc, char **argv)
int fd = ctl_connect(GT_RUNDIR, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd < 0) {
perror("path"); switch (fd) {
ctl_delete(fd); case -1:
perror("path");
break;
case -2:
gt_log("no device\n");
break;
case -3:
gt_log("please choose a device\n");
break;
default:
gt_log("couldn't connect\n");
}
return 1; return 1;
} }

View File

@@ -149,8 +149,20 @@ gt_set(int argc, char **argv)
int fd = ctl_connect(GT_RUNDIR, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd < 0) {
perror("set"); switch (fd) {
case -1:
perror("set");
break;
case -2:
gt_log("no device\n");
break;
case -3:
gt_log("please choose a device\n");
break;
default:
gt_log("couldn't connect\n");
}
return 1; return 1;
} }

View File

@@ -60,8 +60,9 @@ gt_show_dev(const char *dev)
{ {
int fd = ctl_connect(GT_RUNDIR, dev); int fd = ctl_connect(GT_RUNDIR, dev);
if (fd == -1) { if (fd < 0) {
perror(dev); if (fd == -1)
perror("show");
return -1; return -1;
} }