mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-09 13:02:01 +03:00
(unlock_file): eliminate goto, reduce variable scopes.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
fded68057e
commit
54ec89d950
26
lib/lock.c
26
lib/lock.c
@ -279,8 +279,7 @@ int
|
|||||||
unlock_file (const vfs_path_t * fname_vpath)
|
unlock_file (const vfs_path_t * fname_vpath)
|
||||||
{
|
{
|
||||||
char *lockfname;
|
char *lockfname;
|
||||||
struct stat statbuf;
|
const char *elpath;
|
||||||
const char *elpath, *lock;
|
|
||||||
|
|
||||||
if (fname_vpath == NULL)
|
if (fname_vpath == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@ -291,27 +290,24 @@ unlock_file (const vfs_path_t * fname_vpath)
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
lockfname = lock_build_symlink_name (fname_vpath);
|
lockfname = lock_build_symlink_name (fname_vpath);
|
||||||
|
if (lockfname != NULL)
|
||||||
if (lockfname == NULL)
|
{
|
||||||
return 0;
|
struct stat statbuf;
|
||||||
|
|
||||||
/* Check if lock exists */
|
/* Check if lock exists */
|
||||||
if (lstat (lockfname, &statbuf) == -1)
|
if (lstat (lockfname, &statbuf) != -1)
|
||||||
goto ret;
|
{
|
||||||
|
const char *lock;
|
||||||
|
|
||||||
lock = lock_get_info (lockfname);
|
lock = lock_get_info (lockfname);
|
||||||
if (lock != NULL)
|
|
||||||
{
|
|
||||||
/* Don't touch if lock is not ours */
|
/* Don't touch if lock is not ours */
|
||||||
if (lock_extract_info (lock)->pid != getpid ())
|
if (lock == NULL || lock_extract_info (lock)->pid == getpid ())
|
||||||
goto ret;
|
unlink (lockfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove lock */
|
|
||||||
unlink (lockfname);
|
|
||||||
|
|
||||||
ret:
|
|
||||||
g_free (lockfname);
|
g_free (lockfname);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user