projects
/
mkmisc.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move call to basename() into misc_get_minor()
[mkmisc.git]
/
mkmisc.c
diff --git
a/mkmisc.c
b/mkmisc.c
index
4e6b0bc
..
fb548e4
100644
(file)
--- a/
mkmisc.c
+++ b/
mkmisc.c
@@
-60,11
+60,13
@@
static int misc_get_major(void)
return -1;
}
return -1;
}
-static int misc_get_minor(char *
nod
e)
+static int misc_get_minor(char *
devic
e)
{
FILE *fp;
int minor;
char name[64];
{
FILE *fp;
int minor;
char name[64];
+ char *path;
+ char *node;
fp = fopen("/proc/misc", "r");
if (fp == NULL) {
fp = fopen("/proc/misc", "r");
if (fp == NULL) {
@@
-72,12
+74,17
@@
static int misc_get_minor(char *node)
return -1;
}
return -1;
}
+ path = strdup(device);
+ node = basename(path);
+
while (fscanf(fp, "%d %64s", &minor, name) == 2) {
if (strcmp(name, node) == 0) {
while (fscanf(fp, "%d %64s", &minor, name) == 2) {
if (strcmp(name, node) == 0) {
+ free(path);
fclose(fp);
return minor;
}
}
fclose(fp);
return minor;
}
}
+ free(path);
fclose(fp);
return -1;
fclose(fp);
return -1;
@@
-85,8
+92,6
@@
static int misc_get_minor(char *node)
static int mkmisc(char *device)
{
static int mkmisc(char *device)
{
- char *path;
- char *node;
int major;
int minor;
dev_t dev;
int major;
int minor;
dev_t dev;
@@
-98,16
+103,11
@@
static int mkmisc(char *device)
return major;
}
return major;
}
- path = strdup(device);
- node = basename(path);
-
- minor = misc_get_minor(node);
+ minor = misc_get_minor(device);
if (minor < 0) {
fprintf(stderr, "Cannot get misc minor for %s\n", device);
if (minor < 0) {
fprintf(stderr, "Cannot get misc minor for %s\n", device);
- free(path);
return minor;
}
return minor;
}
- free(path);
if (verbose)
printf("Creating device: %s, major: %d, minor: %d\n",
if (verbose)
printf("Creating device: %s, major: %d, minor: %d\n",