mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
lvmlockd: clean up get_local_nodeid
Hard to see if fclose calls were correct, and coverity couldn't figure it out either, so make it clear.
This commit is contained in:
parent
cd14d3fcc0
commit
da44f2b6fe
@ -227,8 +227,9 @@ static int get_local_nodeid(void)
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
char ls_comms_path[PATH_MAX];
|
||||
FILE *file = NULL;
|
||||
FILE *file;
|
||||
char line[LOCK_LINE_MAX];
|
||||
char *str1, *str2;
|
||||
int rv = -1, val;
|
||||
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
@ -243,30 +244,33 @@ static int get_local_nodeid(void)
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/local",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
file = fopen(ls_comms_path, "r");
|
||||
if (!file)
|
||||
|
||||
if (!(file = fopen(ls_comms_path, "r")))
|
||||
continue;
|
||||
if (fgets(line, LOCK_LINE_MAX, file)) {
|
||||
fclose(file);
|
||||
str1 = fgets(line, LOCK_LINE_MAX, file);
|
||||
fclose(file);
|
||||
|
||||
if (str1) {
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if ((rv == 1) && (val == 1 )) {
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/nodeid",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
file = fopen(ls_comms_path, "r");
|
||||
if (!file)
|
||||
|
||||
if (!(file = fopen(ls_comms_path, "r")))
|
||||
continue;
|
||||
if (fgets(line, LOCK_LINE_MAX, file)) {
|
||||
str2 = fgets(line, LOCK_LINE_MAX, file);
|
||||
fclose(file);
|
||||
|
||||
if (str2) {
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if (rv == 1) {
|
||||
fclose(file);
|
||||
closedir(ls_dir);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
if (closedir(ls_dir))
|
||||
|
Loading…
Reference in New Issue
Block a user