summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYunhee Seo <yuni.seo@samsung.com>2024-07-15 20:47:57 +0900
committerYunhee Seo <yuni.seo@samsung.com>2024-07-15 20:47:57 +0900
commit9d070ab520b86118dc9a55678dcc6c8066ce1b33 (patch)
tree29da829eafc629996dfcbf8f5037ea462428b158
parent546be29313cd4d17d49e54e32bd9e4b9cacf0dab (diff)
downloadlibsyscommon-9d070ab520b86118dc9a55678dcc6c8066ce1b33.tar.gz
libsyscommon-9d070ab520b86118dc9a55678dcc6c8066ce1b33.tar.bz2
libsyscommon-9d070ab520b86118dc9a55678dcc6c8066ce1b33.zip
When comparing two strings, it is not clear what values are contained in the case where they are obtained from an array. Thus, using sizeof literal is more clear in terms of readability and maintenance. This is meaningful especially when the array does not contain proper values or is empty. Change-Id: Ic427c15767640c20a3e6aaaaa68763a66085ef64 Signed-off-by: Yunhee Seo <yuni.seo@samsung.com>
-rw-r--r--src/libcommon/proc.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/libcommon/proc.c b/src/libcommon/proc.c
index 16c439f..12ea071 100644
--- a/src/libcommon/proc.c
+++ b/src/libcommon/proc.c
@@ -79,7 +79,6 @@ int syscommon_proc_get_attr_current(pid_t pid, char *buf, int len)
int syscommon_proc_is_app(pid_t pid)
{
char attr[NAME_MAX] = { 0 ,};
- size_t len = 0;
int ret = 0;
ret = syscommon_proc_get_attr_current(pid, attr, sizeof(attr));
@@ -88,15 +87,13 @@ int syscommon_proc_is_app(pid_t pid)
return -1;
}
- len = strlen(attr) + 1;
-
- if (!strncmp("System", attr, len))
+ if (!strncmp("System", attr, sizeof("System")))
return 0;
- if (!strncmp("User", attr, len))
+ if (!strncmp("User", attr, sizeof("User")))
return 0;
- if (!strncmp("System::Privileged", attr, len))
+ if (!strncmp("System::Privileged", attr, sizeof("System::Privileged")))
return 0;
return 1;