[glib: 1/2] [PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/2] [PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop
- Date: Mon, 27 Jun 2022 11:14:05 +0000 (UTC)
commit 02d0d6497b92d05d1145d1077654ad2453938b6c
Author: Rozhuk Ivan <rozhuk im gmail com>
Date: Sat Jun 25 19:01:30 2022 +0300
[PATCH] _g_get_unix_mount_points(): reduce syscalls inside loop
gio/gunixmounts.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/gio/gunixmounts.c b/gio/gunixmounts.c
index 563bdba3b2..155c02c6fb 100644
--- a/gio/gunixmounts.c
+++ b/gio/gunixmounts.c
@@ -1412,6 +1412,7 @@ _g_get_unix_mount_points (void)
GUnixMountPoint *mount_point;
GList *return_list;
#ifdef HAVE_SYS_SYSCTL_H
+ uid_t uid = getuid ();
int usermnt = 0;
struct stat sb;
#endif
@@ -1462,14 +1463,13 @@ _g_get_unix_mount_points (void)
#ifdef HAVE_SYS_SYSCTL_H
if (usermnt != 0)
- {
- uid_t uid = getuid ();
- if (stat (fstab->fs_file, &sb) == 0)
- {
- if (uid == 0 || sb.st_uid == uid)
- is_user_mountable = TRUE;
- }
- }
+ {
+ if (uid == 0 ||
+ (stat (fstab->fs_file, &sb) == 0 && sb.st_uid == uid))
+ {
+ is_user_mountable = TRUE;
+ }
+ }
#endif
mount_point = create_unix_mount_point (fstab->fs_spec,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]