diff options
author | merakor <cem@ckyln.com> | 2020-07-23 08:25:15 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-07-23 08:25:15 +0000 |
commit | 3487b71db619ed8e7f4d0a04a6926ea312630707 (patch) | |
tree | cc8834761863facfe2c71b29b6aa43c445b1f4c2 | |
parent | d345be19f3b2026dd3f76228f02e91985bc3a821 (diff) | |
download | cpt-3487b71db619ed8e7f4d0a04a6926ea312630707.tar.gz |
kiss-stat: style changes
FossilOrigin-Name: a396e0a7d4bea5c3f37fd8525fefb002ddff4ce4184dc7f431a93763b8f1216a
-rw-r--r-- | bin/kiss-stat.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/bin/kiss-stat.c b/bin/kiss-stat.c index ebb6f52..4380503 100644 --- a/bin/kiss-stat.c +++ b/bin/kiss-stat.c @@ -14,27 +14,28 @@ struct passwd *pw; struct stat sb; -int main (int argc, char *argv[]) { +int +main (int argc, char *argv[]) +{ + /* Exit if no or multiple arguments are given. */ + if (argc != 2 || strcmp(argv[1], "--help") == 0) { + fprintf(stderr, "Usage: %s [pathname]\n", argv[0]); + return 1; + } - /* Exit if no or multiple arguments are given. */ - if (argc != 2 || strcmp(argv[1], "--help") == 0) { - fprintf(stderr, "Usage: %s [pathname]\n", argv[0]); - return(1); - } + /* Exit if file stat cannot be obtained. */ + if (lstat(argv[1], &sb) == -1) { + perror(argv[0]); + return 1; + } - /* Exit if file stat cannot be obtained. */ - if (lstat(argv[1], &sb) == -1) { - perror(argv[0]); - return(1); - } + /* Exit if name of the owner cannot be retrieved. */ + if (!getpwuid(sb.st_uid)) { + return 1; + } - /* Exit if name of the owner cannot be retrieved. */ - if (!getpwuid(sb.st_uid)) { - return(1); - } - - /* Print the user name of file owner. */ - pw = getpwuid(sb.st_uid); - printf("%s\n", pw->pw_name); - return(0); -} + /* Print the user name of file owner. */ + pw = getpwuid(sb.st_uid); + printf("%s\n", pw->pw_name); + return 0; +} |