Use _PATH_DEV (from paths.h) for the "/dev/" string, rather than

hard-coding it.

Sponsored by:	Intel
Suggested by:	kib
Reviewed by:	kib, carl
MFC after:	3 days
This commit is contained in:
Jim Harris 2013-07-18 23:25:57 +00:00
parent b378da2781
commit dddb618e3f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=253459
2 changed files with 4 additions and 2 deletions

View File

@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$");
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <paths.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -82,7 +83,7 @@ devlist(int argc, char *argv[])
if (ret != 0) { if (ret != 0) {
if (ret == EACCES) { if (ret == EACCES) {
warnx("could not open /dev/%s\n", name); warnx("could not open "_PATH_DEV"%s\n", name);
continue; continue;
} else } else
break; break;

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <err.h> #include <err.h>
#include <errno.h> #include <errno.h>
#include <fcntl.h> #include <fcntl.h>
#include <paths.h>
#include <stdbool.h> #include <stdbool.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
@ -175,7 +176,7 @@ open_dev(const char *str, int *fd, int show_error, int exit_on_error)
return (EINVAL); return (EINVAL);
} }
snprintf(full_path, sizeof(full_path), "/dev/%s", str); snprintf(full_path, sizeof(full_path), _PATH_DEV"%s", str);
*fd = open(full_path, O_RDWR); *fd = open(full_path, O_RDWR);
if (*fd < 0) { if (*fd < 0) {
if (show_error) if (show_error)