summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-10-25 11:30:57 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-10-25 11:30:57 +0200
commit4a4fd954141d1fb4410bf90b00e6f6c8a6540579 (patch)
tree5e8e36a4879ce90151e23586315676e929c5c055
parent1c7bbc7f2c7dd7e528371fdb6ccebdc3fd884e4f (diff)
database: call getuid only once
Change-Id: I249c0b712a66016bb578f203dc62ecaf6dac2b91 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--ll-database-binding/src/ll-database-binding.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/ll-database-binding/src/ll-database-binding.c b/ll-database-binding/src/ll-database-binding.c
index bbbba80..e878896 100644
--- a/ll-database-binding/src/ll-database-binding.c
+++ b/ll-database-binding/src/ll-database-binding.c
@@ -72,11 +72,12 @@ static int get_database_path(char *buffer, size_t size)
rc = snprintf(buffer, size, "%s/.config/%s", home, dbfile);
else
{
- struct passwd *pwd = getpwuid(getuid());
+ uid_t uid = getuid();
+ struct passwd *pwd = getpwuid(uid);
if (pwd)
rc = snprintf(buffer, size, "%s/.config/%s", pwd->pw_dir, dbfile);
else
- rc = snprintf(buffer, size, "/home/%d/.config/%s", (int)getuid(), dbfile);
+ rc = snprintf(buffer, size, "/home/%d/.config/%s", (int)uid, dbfile);
}
}
return rc;