diff options
Diffstat (limited to 'Userland')
48 files changed, 260 insertions, 257 deletions
diff --git a/Userland/al.cpp b/Userland/al.cpp index d5b2cad0fd..96094d5d6c 100644 --- a/Userland/al.cpp +++ b/Userland/al.cpp @@ -1,6 +1,6 @@ -#include <unistd.h> #include <signal.h> #include <stdio.h> +#include <unistd.h> static volatile bool got_alarm = false; @@ -11,7 +11,7 @@ int main(int c, char** v) ret = alarm(2); printf("alarm() with an alarm(5) set: %u\n", ret); - signal(SIGALRM, [] (int) { + signal(SIGALRM, [](int) { got_alarm = true; }); printf("Entering infinite loop.\n"); diff --git a/Userland/cat.cpp b/Userland/cat.cpp index 4b86ea9a14..e03801487d 100644 --- a/Userland/cat.cpp +++ b/Userland/cat.cpp @@ -1,10 +1,10 @@ -#include <stdio.h> -#include <unistd.h> +#include <assert.h> #include <errno.h> -#include <string.h> -#include <stdlib.h> #include <fcntl.h> -#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> int main(int argc, char** argv) { diff --git a/Userland/chmod.cpp b/Userland/chmod.cpp index 496762226d..e4057af0c0 100644 --- a/Userland/chmod.cpp +++ b/Userland/chmod.cpp @@ -1,9 +1,9 @@ -#include <unistd.h> -#include <sys/stat.h> #include <stdio.h> #include <string.h> +#include <sys/stat.h> +#include <unistd.h> -int main(int argc, char **argv) +int main(int argc, char** argv) { if (argc != 3) { printf("usage: chmod <octal-mode> <path>\n"); diff --git a/Userland/chown.cpp b/Userland/chown.cpp index e5b2be2a36..256e82e81f 100644 --- a/Userland/chown.cpp +++ b/Userland/chown.cpp @@ -1,10 +1,10 @@ -#include <unistd.h> -#include <sys/stat.h> +#include <AK/AKString.h> #include <stdio.h> #include <string.h> -#include <AK/AKString.h> +#include <sys/stat.h> +#include <unistd.h> -int main(int argc, char **argv) +int main(int argc, char** argv) { if (argc < 2) { printf("usage: chown <uid[:gid]> <path>\n"); diff --git a/Userland/clear.cpp b/Userland/clear.cpp index e31f99328b..6cdedc3ec7 100644 --- a/Userland/clear.cpp +++ b/Userland/clear.cpp @@ -6,4 +6,3 @@ int main(int, char**) fflush(stdout); return 0; } - diff --git a/Userland/cp.cpp b/Userland/cp.cpp index bfc263e0aa..03e3e0411c 100644 --- a/Userland/cp.cpp +++ b/Userland/cp.cpp @@ -1,11 +1,11 @@ -#include <unistd.h> -#include <fcntl.h> +#include <AK/AKString.h> +#include <AK/FileSystemPath.h> +#include <AK/StringBuilder.h> #include <assert.h> +#include <fcntl.h> #include <stdio.h> #include <sys/stat.h> -#include <AK/AKString.h> -#include <AK/StringBuilder.h> -#include <AK/FileSystemPath.h> +#include <unistd.h> int main(int argc, char** argv) { diff --git a/Userland/crash.cpp b/Userland/crash.cpp index f19b714d6d..ddef7531e9 100644 --- a/Userland/crash.cpp +++ b/Userland/crash.cpp @@ -10,7 +10,13 @@ static void print_usage_and_exit() int main(int argc, char** argv) { - enum Mode { SegmentationViolation, DivisionByZero, IllegalInstruction, Abort }; + enum Mode + { + SegmentationViolation, + DivisionByZero, + IllegalInstruction, + Abort + }; Mode mode = SegmentationViolation; if (argc != 2) diff --git a/Userland/date.cpp b/Userland/date.cpp index d280a7434f..90edd680c4 100644 --- a/Userland/date.cpp +++ b/Userland/date.cpp @@ -1,6 +1,6 @@ -#include <time.h> #include <stdio.h> #include <string.h> +#include <time.h> int main(int argc, char** argv) { @@ -21,4 +21,3 @@ int main(int argc, char** argv) tm->tm_sec); return 0; } - diff --git a/Userland/df.cpp b/Userland/df.cpp index 62572921aa..875aaa0d11 100644 --- a/Userland/df.cpp +++ b/Userland/df.cpp @@ -1,9 +1,9 @@ -#include <stdio.h> -#include <unistd.h> -#include <fcntl.h> -#include <stdlib.h> #include <AK/AKString.h> #include <AK/Vector.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> struct FileSystem { String fs; diff --git a/Userland/dmesg.cpp b/Userland/dmesg.cpp index f8b3b48db1..bc558815fc 100644 --- a/Userland/dmesg.cpp +++ b/Userland/dmesg.cpp @@ -1,13 +1,13 @@ +#include <LibCore/CFile.h> +#include <assert.h> +#include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <fcntl.h> -#include <assert.h> -#include <LibCore/CFile.h> int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; CFile f("/proc/dmesg"); if (!f.open(CIODevice::ReadOnly)) { fprintf(stderr, "open: failed to open /proc/dmesg: %s", f.error_string()); diff --git a/Userland/env.cpp b/Userland/env.cpp index 0a2a0e39d5..dc1e8b26db 100644 --- a/Userland/env.cpp +++ b/Userland/env.cpp @@ -1,5 +1,5 @@ -#include <unistd.h> #include <stdio.h> +#include <unistd.h> int main(int, char**) { diff --git a/Userland/fgrep.cpp b/Userland/fgrep.cpp index 8916d1131a..c24c3fa76a 100644 --- a/Userland/fgrep.cpp +++ b/Userland/fgrep.cpp @@ -1,7 +1,7 @@ +#include <assert.h> #include <stdio.h> #include <string.h> #include <unistd.h> -#include <assert.h> int main(int argc, char** argv) { diff --git a/Userland/guitest2.cpp b/Userland/guitest2.cpp index 79c229c8f8..21ce0fd2a5 100644 --- a/Userland/guitest2.cpp +++ b/Userland/guitest2.cpp @@ -1,24 +1,24 @@ -#include <stdio.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <fcntl.h> -#include <assert.h> -#include <time.h> #include <Kernel/Syscall.h> -#include <SharedGraphics/GraphicsBitmap.h> -#include <LibGUI/GPainter.h> -#include <LibGUI/GWindow.h> -#include <LibGUI/GWidget.h> -#include <LibGUI/GLabel.h> -#include <LibGUI/GButton.h> -#include <LibGUI/GTextBox.h> +#include <LibGUI/GApplication.h> #include <LibGUI/GBoxLayout.h> +#include <LibGUI/GButton.h> #include <LibGUI/GCheckBox.h> +#include <LibGUI/GLabel.h> +#include <LibGUI/GPainter.h> #include <LibGUI/GProgressBar.h> -#include <LibGUI/GApplication.h> +#include <LibGUI/GTextBox.h> +#include <LibGUI/GWidget.h> +#include <LibGUI/GWindow.h> +#include <SharedGraphics/GraphicsBitmap.h> +#include <assert.h> +#include <errno.h> +#include <fcntl.h> #include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> +#include <unistd.h> static GWindow* make_launcher_window(); static GWindow* make_progress_window(); @@ -69,7 +69,7 @@ GWindow* make_launcher_window() terminal_button->set_relative_rect({ 5, 20, 90, 20 }); terminal_button->set_text("Terminal"); - terminal_button->on_click = [label] (GButton&) { + terminal_button->on_click = [label](GButton&) { pid_t child_pid = fork(); if (!child_pid) { execve("/bin/Terminal", nullptr, nullptr); @@ -85,7 +85,7 @@ GWindow* make_launcher_window() guitest_button->set_relative_rect({ 5, 50, 90, 20 }); guitest_button->set_text("guitest"); - guitest_button->on_click = [label] (GButton&) { + guitest_button->on_click = [label](GButton&) { pid_t child_pid = fork(); if (!child_pid) { execve("/bin/guitest", nullptr, nullptr); @@ -120,7 +120,7 @@ GWindow* make_launcher_window() auto* close_button = new GButton(widget); close_button->set_relative_rect({ 5, 200, 90, 20 }); close_button->set_text("Close"); - close_button->on_click = [window] (GButton&) { + close_button->on_click = [window](GButton&) { window->close(); }; @@ -169,7 +169,7 @@ static GWindow* make_frames_window() widget->layout()->set_margins({ 8, 8, 8, 8 }); widget->layout()->set_spacing(8); - auto add_label = [widget] (const String& text, FrameShape shape, FrameShadow shadow) { + auto add_label = [widget](const String& text, FrameShape shape, FrameShadow shadow) { auto* label = new GLabel(text, widget); label->set_size_policy(SizePolicy::Fill, SizePolicy::Fill); label->set_frame_thickness(1); diff --git a/Userland/head.cpp b/Userland/head.cpp index 49ae45ab18..e43e0eca91 100644 --- a/Userland/head.cpp +++ b/Userland/head.cpp @@ -1,7 +1,7 @@ +#include <LibCore/CArgsParser.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> -#include <LibCore/CArgsParser.h> int head(const String& filename, bool print_filename, int line_count); @@ -40,7 +40,7 @@ int main(int argc, char** argv) int rc = 0; - for (auto &file : files) { + for (auto& file : files) { if (head(file, print_filenames, line_count) != 0) { rc = 1; } diff --git a/Userland/host.cpp b/Userland/host.cpp index 52e307ad9b..74f1a0c822 100644 --- a/Userland/host.cpp +++ b/Userland/host.cpp @@ -1,8 +1,8 @@ -#include <netdb.h> #include <arpa/inet.h> +#include <netdb.h> #include <netinet/in.h> -#include <string.h> #include <stdio.h> +#include <string.h> int main(int argc, char** argv) { diff --git a/Userland/hostname.cpp b/Userland/hostname.cpp index 4589da8a5c..d343b5b55e 100644 --- a/Userland/hostname.cpp +++ b/Userland/hostname.cpp @@ -1,12 +1,12 @@ -#include <unistd.h> -#include <stdio.h> #include <errno.h> +#include <stdio.h> #include <string.h> +#include <unistd.h> int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; char buffer[HOST_NAME_MAX]; int rc = gethostname(buffer, sizeof(buffer)); if (rc < 0) { @@ -16,4 +16,3 @@ int main(int argc, char** argv) printf("%s\n", buffer); return 0; } - diff --git a/Userland/id.cpp b/Userland/id.cpp index 9c4a0f24cb..b552f6a528 100644 --- a/Userland/id.cpp +++ b/Userland/id.cpp @@ -1,15 +1,15 @@ -#include <unistd.h> -#include <stdio.h> -#include <pwd.h> -#include <grp.h> #include <alloca.h> +#include <grp.h> +#include <pwd.h> +#include <stdio.h> +#include <unistd.h> extern "C" int main(int, char**); int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; uid_t uid = getuid(); gid_t gid = getgid(); @@ -40,4 +40,3 @@ int main(int argc, char** argv) printf("\n"); return 0; } - diff --git a/Userland/kill.cpp b/Userland/kill.cpp index 7b1cb9a1d1..3a01d4f7eb 100644 --- a/Userland/kill.cpp +++ b/Userland/kill.cpp @@ -1,8 +1,8 @@ -#include <unistd.h> -#include <stdio.h> +#include <AK/AKString.h> #include <signal.h> +#include <stdio.h> #include <stdlib.h> -#include <AK/AKString.h> +#include <unistd.h> static void print_usage_and_exit() { @@ -38,4 +38,3 @@ int main(int argc, char** argv) perror("kill"); return 0; } - diff --git a/Userland/killall.cpp b/Userland/killall.cpp index 11413511a9..85594d8ea8 100644 --- a/Userland/killall.cpp +++ b/Userland/killall.cpp @@ -1,9 +1,9 @@ -#include <unistd.h> -#include <stdio.h> +#include <AK/AKString.h> +#include <LibCore/CProcessStatisticsReader.h> #include <signal.h> +#include <stdio.h> #include <stdlib.h> -#include <LibCore/CProcessStatisticsReader.h> -#include <AK/AKString.h> +#include <unistd.h> static void print_usage_and_exit() { @@ -14,15 +14,15 @@ static void print_usage_and_exit() static int kill_all(const String& process_name, const unsigned signum) { HashMap<pid_t, CProcessStatistics> processes = CProcessStatisticsReader().get_map(); - + for (auto& it : processes) { - if (it.value.name == process_name) { + if (it.value.name == process_name) { int ret = kill(it.value.pid, signum); if (ret < 0) perror("kill"); } } - + return 0; } @@ -31,16 +31,16 @@ int main(int argc, char** argv) bool ok; unsigned signum = SIGTERM; int name_argi = 1; - + if (argc != 2 && argc != 3) print_usage_and_exit(); - + if (argc == 3) { name_argi = 2; - + if (argv[1][0] != '-') print_usage_and_exit(); - + signum = String(&argv[1][1]).to_uint(ok); if (!ok) { printf("'%s' is not a valid signal number\n", &argv[1][1]); diff --git a/Userland/ln.cpp b/Userland/ln.cpp index 9e6a7c1021..54cf0d40d5 100644 --- a/Userland/ln.cpp +++ b/Userland/ln.cpp @@ -1,8 +1,8 @@ -#include <stdio.h> +#include <LibCore/CArgsParser.h> #include <errno.h> -#include <unistd.h> +#include <stdio.h> #include <stdlib.h> -#include <LibCore/CArgsParser.h> +#include <unistd.h> int main(int argc, char** argv) { @@ -35,4 +35,3 @@ int main(int argc, char** argv) } return 0; } - diff --git a/Userland/ls.cpp b/Userland/ls.cpp index b8d92f058e..f5655ac6a5 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -1,18 +1,18 @@ -#include <stdio.h> -#include <unistd.h> +#include <AK/AKString.h> +#include <AK/Vector.h> +#include <LibCore/CDirIterator.h> #include <dirent.h> #include <errno.h> -#include <string.h> -#include <getopt.h> -#include <time.h> #include <fcntl.h> +#include <getopt.h> +#include <grp.h> +#include <pwd.h> +#include <stdio.h> +#include <string.h> #include <sys/ioctl.h> #include <sys/stat.h> -#include <AK/AKString.h> -#include <AK/Vector.h> -#include <LibCore/CDirIterator.h> -#include <pwd.h> -#include <grp.h> +#include <time.h> +#include <unistd.h> static int do_file_system_object_long(const char* path); static int do_file_system_object_short(const char* path); @@ -51,7 +51,7 @@ int main(int argc, char** argv) } } - auto do_file_system_object = [&] (const char* path) { + auto do_file_system_object = [&](const char* path) { if (flag_long) return do_file_system_object_long(path); return do_file_system_object_short(path); @@ -60,7 +60,7 @@ int main(int argc, char** argv) int status; if (optind >= argc) { status = do_file_system_object("."); - } else if (optind+1 >= argc) { + } else if (optind + 1 >= argc) { status = do_file_system_object(argv[optind]); } else { for (; optind < argc; ++optind) { @@ -119,7 +119,8 @@ int print_name(struct stat& st, const char* name, const char* path_for_link_reso return nprinted; } -bool print_filesystem_object(const char* path, const char* name) { +bool print_filesystem_object(const char* path, const char* name) +{ struct stat st; int rc = lstat(path, &st); if (rc == -1) { @@ -155,8 +156,7 @@ bool print_filesystem_object(const char* path, const char* name) { st.st_mode & S_IWGRP ? 'w' : '-', st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'), st.st_mode & S_IROTH ? 'r' : '-', - st.st_mode & S_IWOTH ? 'w' : '-' - ); + st.st_mode & S_IWOTH ? 'w' : '-'); if (st.st_mode & S_ISVTX) printf("t"); @@ -166,14 +166,14 @@ bool print_filesystem_object(const char* path, const char* name) { passwd* pwd = getpwuid(st.st_uid); group* grp = getgrgid(st.st_gid); if (!flag_print_numeric && pwd) { - printf(" %5s", pwd->pw_name); + printf(" %5s", pwd->pw_name); } else { - printf(" %5u", st.st_uid); + printf(" %5u", st.st_uid); } if (!flag_print_numeric && grp) { - printf(" %5s", grp->gr_name); + printf(" %5s", grp->gr_name); } else { - printf(" %5u", st.st_gid); + printf(" %5u", st.st_gid); } if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) @@ -221,8 +221,8 @@ int do_file_system_object_long(const char* path) return 0; } - -bool print_filesystem_object_short(const char *path, const char *name, int *nprinted) { +bool print_filesystem_object_short(const char* path, const char* name, int* nprinted) +{ struct stat st; int rc = lstat(path, &st); if (rc == -1) { diff --git a/Userland/mkdir.cpp b/Userland/mkdir.cpp index c370a1486b..9bfe50b2bc 100644 --- a/Userland/mkdir.cpp +++ b/Userland/mkdir.cpp @@ -1,10 +1,10 @@ -#include <stdio.h> -#include <unistd.h> +#include <assert.h> #include <errno.h> -#include <string.h> +#include <stdio.h> #include <stdlib.h> -#include <assert.h> +#include <string.h> #include <sys/stat.h> +#include <unistd.h> int main(int argc, char** argv) { diff --git a/Userland/mknod.cpp b/Userland/mknod.cpp index dc1221b51d..113aac1702 100644 --- a/Userland/mknod.cpp +++ b/Userland/mknod.cpp @@ -1,7 +1,7 @@ -#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/stat.h> +#include <unistd.h> inline constexpr unsigned encoded_device(unsigned major, unsigned minor) { diff --git a/Userland/mm.cpp b/Userland/mm.cpp index 2a79a55535..e9b734121c 100644 --- a/Userland/mm.cpp +++ b/Userland/mm.cpp @@ -1,12 +1,12 @@ +#include <LibCore/CFile.h> +#include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <fcntl.h> -#include <LibCore/CFile.h> int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; CFile f("/proc/mm"); if (!f.open(CIODevice::ReadOnly)) { diff --git a/Userland/more.cpp b/Userland/more.cpp index d0050c6b9d..6371ef01f4 100644 --- a/Userland/more.cpp +++ b/Userland/more.cpp @@ -1,7 +1,7 @@ -#include <stdio.h> -#include <unistd.h> #include <fcntl.h> +#include <stdio.h> #include <sys/ioctl.h> +#include <unistd.h> static int key_fd; @@ -16,8 +16,8 @@ void wait_for_key() int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; key_fd = open(ttyname(1), O_RDONLY); if (key_fd < 0) { @@ -36,10 +36,9 @@ int main(int argc, char** argv) break; printf(str); ++lines_printed; - if ((lines_printed % (ws.ws_row - 1)) == 0) { + if ((lines_printed % (ws.ws_row - 1)) == 0) { wait_for_key(); } - } close(key_fd); diff --git a/Userland/mv.cpp b/Userland/mv.cpp index 486761c00e..6edf589de3 100644 --- a/Userland/mv.cpp +++ b/Userland/mv.cpp @@ -1,8 +1,8 @@ -#include <stdio.h> -#include <unistd.h> -#include <sys/stat.h> #include <AK/AKString.h> #include <AK/FileSystemPath.h> +#include <stdio.h> +#include <sys/stat.h> +#include <unistd.h> int main(int argc, char** argv) { diff --git a/Userland/pape.cpp b/Userland/pape.cpp index 138b98642d..b77584165d 100644 --- a/Userland/pape.cpp +++ b/Userland/pape.cpp @@ -1,18 +1,18 @@ -#include <stdio.h> -#include <unistd.h> -#include <errno.h> -#include <string.h> -#include <stdlib.h> -#include <fcntl.h> -#include <dirent.h> #include <AK/AKString.h> +#include <AK/FileSystemPath.h> #include <AK/StringBuilder.h> #include <AK/Vector.h> -#include <AK/FileSystemPath.h> #include <LibCore/CArgsParser.h> #include <LibCore/CDirIterator.h> -#include <LibGUI/GDesktop.h> #include <LibGUI/GApplication.h> +#include <LibGUI/GDesktop.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> static int handle_show_all() { @@ -73,4 +73,3 @@ int main(int argc, char** argv) return handle_set_pape(values[0]); } - diff --git a/Userland/pidof.cpp b/Userland/pidof.cpp index 09ce327ff1..ea2cb4c57a 100644 --- a/Userland/pidof.cpp +++ b/Userland/pidof.cpp @@ -1,21 +1,21 @@ -#include <unistd.h> -#include <stdio.h> -#include <signal.h> -#include <stdlib.h> -#include <LibCore/CProcessStatisticsReader.h> -#include <LibCore/CArgsParser.h> #include <AK/AKString.h> -#include <AK/Vector.h> #include <AK/HashMap.h> +#include <AK/Vector.h> +#include <LibCore/CArgsParser.h> +#include <LibCore/CProcessStatisticsReader.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> static int pid_of(const String& process_name, bool single_shot, bool omit_pid, pid_t pid) { bool displayed_at_least_one = false; HashMap<pid_t, CProcessStatistics> processes = CProcessStatisticsReader().get_map(); - + for (auto& it : processes) { - if (it.value.name == process_name) { + if (it.value.name == process_name) { if (!omit_pid || (omit_pid && it.value.pid != pid)) { printf("%d ", it.value.pid); displayed_at_least_one = true; @@ -40,11 +40,11 @@ int main(int argc, char** argv) args_parser.add_arg("o", "pid", "Tells pidof to omit processes with that pid. The special pid %PPID can be used to name the parent process of the pidof program."); CArgsParserResult args = args_parser.parse(argc, (const char**)argv); - + bool s_arg = args.is_present("s"); bool o_arg = args.is_present("o"); pid_t pid = 0; - + if (o_arg) { bool ok = false; String pid_str = args.get("o"); @@ -54,13 +54,13 @@ int main(int argc, char** argv) else pid = pid_str.to_uint(ok); } - + // We should have one single value : the process name Vector<String> values = args.get_single_values(); if (values.size() == 0) { args_parser.print_usage(); return 0; } - + return pid_of(values[0], s_arg, o_arg, pid); } diff --git a/Userland/ping.cpp b/Userland/ping.cpp index 05a63d0b66..9151c0df72 100644 --- a/Userland/ping.cpp +++ b/Userland/ping.cpp @@ -1,17 +1,17 @@ -#include <sys/socket.h> -#include <sys/time.h> #include <arpa/inet.h> -#include <netinet/ip_icmp.h> +#include <netdb.h> #include <netinet/in.h> +#include <netinet/ip_icmp.h> #include <stdio.h> #include <string.h> -#include <unistd.h> -#include <netdb.h> +#include <sys/socket.h> +#include <sys/time.h> #include <time.h> +#include <unistd.h> uint16_t internet_checksum(const void* ptr, size_t count) { - uint32_t checksum = 0; + uint32_t checksum = 0; auto* w = (const uint16_t*)ptr; while (count > 1) { checksum += ntohs(*w++); @@ -47,7 +47,9 @@ int main(int argc, char** argv) return 1; } - struct timeval timeout { 1, 0 }; + struct timeval timeout { + 1, 0 + }; int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); if (rc < 0) { perror("setsockopt"); @@ -131,8 +133,7 @@ int main(int argc, char** argv) ntohs(pong_packet.header.un.echo.id), ntohs(pong_packet.header.un.echo.sequence), pong_packet.header.un.echo.sequence != ping_packet.header.un.echo.sequence ? "(!)" : "", - ms - ); + ms); // If this was a response to an earlier packet, we still need to wait for the current one. if (pong_packet.header.un.echo.sequence != ping_packet.header.un.echo.sequence) diff --git a/Userland/ps.cpp b/Userland/ps.cpp index 4fd0c4aa0a..2485b36057 100644 --- a/Userland/ps.cpp +++ b/Userland/ps.cpp @@ -1,12 +1,12 @@ +#include <LibCore/CFile.h> +#include <fcntl.h> #include <stdio.h> #include <unistd.h> -#include <fcntl.h> -#include <LibCore/CFile.h> int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; CFile f("/proc/summary"); if (!f.open(CIODevice::ReadOnly)) { diff --git a/Userland/qs.cpp b/Userland/qs.cpp index e3b5c49cb9..f3ab074af9 100644 --- a/Userland/qs.cpp +++ b/Userland/qs.cpp @@ -1,11 +1,11 @@ -#include <SharedGraphics/PNGLoader.h> +#include <LibGUI/GAction.h> #include <LibGUI/GApplication.h> -#include <LibGUI/GWindow.h> -#include <LibGUI/GLabel.h> #include <LibGUI/GBoxLayout.h> -#include <LibGUI/GMenuBar.h> +#include <LibGUI/GLabel.h> #include <LibGUI/GMenu.h> -#include <LibGUI/GAction.h> +#include <LibGUI/GMenuBar.h> +#include <LibGUI/GWindow.h> +#include <SharedGraphics/PNGLoader.h> #include <stdio.h> int main(int argc, char** argv) @@ -15,7 +15,7 @@ int main(int argc, char** argv) auto menubar = make<GMenuBar>(); auto app_menu = make<GMenu>("QuickShow"); - app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [] (const GAction&) { + app_menu->add_action(GAction::create("Quit", { Mod_Alt, Key_F4 }, [](const GAction&) { GApplication::the().quit(0); return; })); @@ -25,7 +25,7 @@ int main(int argc, char** argv) menubar->add_menu(move(file_menu)); auto help_menu = make<GMenu>("Help"); - help_menu->add_action(GAction::create("About", [] (const GAction&) { + help_menu->add_action(GAction::create("About", [](const GAction&) { dbgprintf("FIXME: Implement Help/About\n"); })); menubar->add_menu(move(help_menu)); diff --git a/Userland/rmdir.cpp b/Userland/rmdir.cpp index 8d84f8cc67..8d802139b6 100644 --- a/Userland/rmdir.cpp +++ b/Userland/rmdir.cpp @@ -1,5 +1,5 @@ -#include <stdio.h> #include <errno.h> +#include <stdio.h> #include <unistd.h> int main(int argc, char** argv) @@ -15,4 +15,3 @@ int main(int argc, char** argv) } return 0; } - diff --git a/Userland/sleep.cpp b/Userland/sleep.cpp index 25aa3732f8..a91001cc40 100644 --- a/Userland/sleep.cpp +++ b/Userland/sleep.cpp @@ -1,7 +1,7 @@ -#include <unistd.h> -#include <stdio.h> -#include <signal.h> #include <AK/AKString.h> +#include <signal.h> +#include <stdio.h> +#include <unistd.h> void handle_sigint(int) { @@ -29,4 +29,3 @@ int main(int argc, char** argv) } return 0; } - diff --git a/Userland/sort.cpp b/Userland/sort.cpp index 35d3933f9e..543a1185c3 100644 --- a/Userland/sort.cpp +++ b/Userland/sort.cpp @@ -1,6 +1,6 @@ +#include <AK/AKString.h> #include <AK/QuickSort.h> #include <AK/Vector.h> -#include <AK/AKString.h> #include <stdio.h> #include <stdlib.h> @@ -16,7 +16,7 @@ int main(int argc, char** argv) lines.append(buffer); } - quick_sort(lines.begin(), lines.end(), [] (auto& a, auto& b) { + quick_sort(lines.begin(), lines.end(), [](auto& a, auto& b) { return strcmp(a.characters(), b.characters()) < 0; }); diff --git a/Userland/stat.cpp b/Userland/stat.cpp index fc6154f074..cab32139b9 100644 --- a/Userland/stat.cpp +++ b/Userland/stat.cpp @@ -1,9 +1,9 @@ -#include <stdio.h> -#include <unistd.h> -#include <time.h> -#include <pwd.h> #include <grp.h> +#include <pwd.h> +#include <stdio.h> #include <sys/stat.h> +#include <time.h> +#include <unistd.h> int main(int argc, char** argv) { @@ -62,8 +62,7 @@ int main(int argc, char** argv) st.st_mode & S_IWGRP ? 'w' : '-', st.st_mode & S_ISGID ? 's' : (st.st_mode & S_IXGRP ? 'x' : '-'), st.st_mode & S_IROTH ? 'r' : '-', - st.st_mode & S_IWOTH ? 'w' : '-' - ); + st.st_mode & S_IWOTH ? 'w' : '-'); if (st.st_mode & S_ISVTX) printf("t"); @@ -72,7 +71,7 @@ int main(int argc, char** argv) printf(")\n"); - auto print_time = [] (time_t t) { + auto print_time = [](time_t t) { auto* tm = localtime(&t); printf("%4u-%02u-%02u %02u:%02u:%02u\n", tm->tm_year + 1900, diff --git a/Userland/strace.cpp b/Userland/strace.cpp index bd8b9cf61b..786479aade 100644 --- a/Userland/strace.cpp +++ b/Userland/strace.cpp @@ -1,11 +1,11 @@ -#include <stdio.h> -#include <unistd.h> -#include <stdlib.h> -#include <string.h> -#include <signal.h> #include <AK/Assertions.h> #include <AK/Types.h> #include <Kernel/Syscall.h> +#include <signal.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> static int usage() { diff --git a/Userland/su.cpp b/Userland/su.cpp index 354d97aa76..8f7a10aa82 100644 --- a/Userland/su.cpp +++ b/Userland/su.cpp @@ -1,8 +1,8 @@ -#include <unistd.h> -#include <stdio.h> -#include <pwd.h> -#include <grp.h> #include <alloca.h> +#include <grp.h> +#include <pwd.h> +#include <stdio.h> +#include <unistd.h> extern "C" int main(int, char**); diff --git a/Userland/sysctl.cpp b/Userland/sysctl.cpp index 90fead0f2d..29e8c7f768 100644 --- a/Userland/sysctl.cpp +++ b/Userland/sysctl.cpp @@ -1,15 +1,15 @@ -#include <stdio.h> -#include <unistd.h> -#include <dirent.h> -#include <errno.h> -#include <string.h> -#include <fcntl.h> #include <AK/AKString.h> #include <AK/StringBuilder.h> #include <AK/Vector.h> #include <LibCore/CArgsParser.h> #include <LibCore/CDirIterator.h> #include <LibCore/CFile.h> +#include <dirent.h> +#include <errno.h> +#include <fcntl.h> +#include <stdio.h> +#include <string.h> +#include <unistd.h> static String read_var(const String& name) { @@ -48,7 +48,6 @@ static void write_var(const String& name, const String& value) } } - static int handle_show_all() { CDirIterator di("/proc/sys", CDirIterator::SkipDots); @@ -102,4 +101,3 @@ int main(int argc, char** argv) Vector<String> values = args.get_single_values(); return handle_var(values[0]); } - diff --git a/Userland/tail.cpp b/Userland/tail.cpp index 8fe43d992a..0da99fa910 100644 --- a/Userland/tail.cpp +++ b/Userland/tail.cpp @@ -1,11 +1,11 @@ +#include <AK/Assertions.h> +#include <LibCore/CArgsParser.h> +#include <LibCore/CFile.h> +#include <errno.h> #include <stdio.h> -#include <string.h> #include <stdlib.h> -#include <errno.h> +#include <string.h> #include <unistd.h> -#include <AK/Assertions.h> -#include <LibCore/CFile.h> -#include <LibCore/CArgsParser.h> #define DEFAULT_LINE_COUNT 10 @@ -50,7 +50,7 @@ off_t find_seek_pos(CFile& file, int wanted_lines) // FIXME: Reading char-by-char is only OK if CIODevice's read buffer // is smart enough to not read char-by-char. Fix it there, or fix it here :) - for(; pos >= 0; pos--) { + for (; pos >= 0; pos--) { file.seek(pos); const auto& ch = file.read(1); if (ch.is_empty()) { @@ -74,7 +74,7 @@ static void exit_because_we_wanted_lines() exit(1); } -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { CArgsParser args_parser("tail"); @@ -98,7 +98,7 @@ int main(int argc, char *argv[]) return 1; } } else { - line_count = DEFAULT_LINE_COUNT; + line_count = DEFAULT_LINE_COUNT; } CFile f(values[0]); diff --git a/Userland/tc.cpp b/Userland/tc.cpp index 408cbab3fb..7abf31c9af 100644 --- a/Userland/tc.cpp +++ b/Userland/tc.cpp @@ -18,9 +18,11 @@ int main(int argc, char** argv) if (fd < 0) { perror("socket"); return 1; - } + } - struct timeval timeout { 3, 0 }; + struct timeval timeout { + 3, 0 + }; int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); if (rc < 0) { perror("setsockopt"); diff --git a/Userland/tee.cpp b/Userland/tee.cpp index 51b0c05354..d4bded2dd5 100644 --- a/Userland/tee.cpp +++ b/Userland/tee.cpp @@ -120,4 +120,3 @@ int main(int argc, char** argv) return (err_open || err_write) ? 1 : 0; } - diff --git a/Userland/top.cpp b/Userland/top.cpp index a0c3350049..352947c69a 100644 --- a/Userland/top.cpp +++ b/Userland/top.cpp @@ -1,12 +1,12 @@ -#include <stdio.h> -#include <unistd.h> +#include <AK/AKString.h> +#include <AK/HashMap.h> +#include <AK/QuickSort.h> +#include <AK/Vector.h> #include <fcntl.h> #include <pwd.h> +#include <stdio.h> #include <stdlib.h> -#include <AK/HashMap.h> -#include <AK/AKString.h> -#include <AK/Vector.h> -#include <AK/QuickSort.h> +#include <unistd.h> static HashMap<unsigned, String>* s_usernames; @@ -89,14 +89,14 @@ int main(int, char**) printf("\033[3J\033[H\033[2J"); printf("\033[47;30m%6s %3s % 8s % 8s %6s %6s %4s %s\033[K\033[0m\n", - "PID", - "PRI", - "USER", - "STATE", - "LINEAR", - "COMMIT", - "%CPU", - "NAME"); + "PID", + "PRI", + "USER", + "STATE", + "LINEAR", + "COMMIT", + "%CPU", + "NAME"); for (auto& it : current.map) { pid_t pid = it.key; if (pid == 0) @@ -108,13 +108,12 @@ int main(int, char**) dword nsched_before = (*jt).value.nsched; dword nsched_diff = nsched_now - nsched_before; it.value.nsched_since_prev = nsched_diff; - it.value.cpu_percent = ((nsched_diff * 100)/ sum_diff); - it.value.cpu_percent_decimal = (((nsched_diff * 1000)/ sum_diff) % 10); + it.value.cpu_percent = ((nsched_diff * 100) / sum_diff); + it.value.cpu_percent_decimal = (((nsched_diff * 1000) / sum_diff) % 10); processes.append(&it.value); } - - quick_sort(processes.begin(), processes.end(), [] (auto* p1, auto* p2) { + quick_sort(processes.begin(), processes.end(), [](auto* p1, auto* p2) { return p2->nsched_since_prev < p1->nsched_since_prev; }); @@ -128,8 +127,7 @@ int main(int, char**) process->committed / 1024, process->cpu_percent, process->cpu_percent_decimal, - process->name.characters() - ); + process->name.characters()); } processes.clear_with_capacity(); prev = move(current); diff --git a/Userland/touch.cpp b/Userland/touch.cpp index 690e6d8671..8674a5b949 100644 --- a/Userland/touch.cpp +++ b/Userland/touch.cpp @@ -1,11 +1,11 @@ -#include <stdio.h> #include <errno.h> -#include <utime.h> #include <fcntl.h> -#include <unistd.h> +#include <stdio.h> #include <stdlib.h> -#include <sys/types.h> #include <sys/stat.h> +#include <sys/types.h> +#include <unistd.h> +#include <utime.h> static bool file_exists(const char* path) { @@ -46,4 +46,3 @@ int main(int argc, char** argv) } return 0; } - diff --git a/Userland/tr.cpp b/Userland/tr.cpp index c9be4b0f3a..36b294318f 100644 --- a/Userland/tr.cpp +++ b/Userland/tr.cpp @@ -1,6 +1,6 @@ +#include <AK/AKString.h> #include <AK/QuickSort.h> #include <AK/Vector.h> -#include <AK/AKString.h> #include <stdio.h> #include <stdlib.h> diff --git a/Userland/tst.cpp b/Userland/tst.cpp index bea9c63e61..b94ae2e486 100644 --- a/Userland/tst.cpp +++ b/Userland/tst.cpp @@ -1,11 +1,11 @@ #include <stdio.h> -#include <unistd.h> #include <sys/ioctl.h> +#include <unistd.h> int main(int argc, char** argv) { - (void) argc; - (void) argv; + (void)argc; + (void)argv; struct winsize ws; int rc = ioctl(0, TIOCGWINSZ, &ws); diff --git a/Userland/uc.cpp b/Userland/uc.cpp index 4ef617616e..5fe908ee54 100644 --- a/Userland/uc.cpp +++ b/Userland/uc.cpp @@ -18,9 +18,11 @@ int main(int argc, char** argv) if (fd < 0) { perror("socket"); return 1; - } + } - struct timeval timeout { 5, 0 }; + struct timeval timeout { + 5, 0 + }; int rc = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)); if (rc < 0) { perror("setsockopt"); @@ -41,12 +43,12 @@ int main(int argc, char** argv) char buffer[BUFSIZ]; const char* msg = "Test message"; - sendto(fd, (const char *)msg, strlen(msg), 0,(const struct sockaddr *)&dst_addr, sizeof(dst_addr)); + sendto(fd, (const char*)msg, strlen(msg), 0, (const struct sockaddr*)&dst_addr, sizeof(dst_addr)); printf("Message sent.\n"); struct sockaddr_in src_addr; socklen_t src_addr_len = sizeof(src_addr); - ssize_t nrecv = recvfrom(fd, (char *)buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len); + ssize_t nrecv = recvfrom(fd, (char*)buffer, sizeof(buffer), 0, (struct sockaddr*)&src_addr, &src_addr_len); if (nrecv < 0) { perror("recvfrom"); return 1; diff --git a/Userland/uname.cpp b/Userland/uname.cpp index 64e43c3565..98987e0d40 100644 --- a/Userland/uname.cpp +++ b/Userland/uname.cpp @@ -20,11 +20,21 @@ int main(int argc, char** argv) if (argv[i][0] == '-') { for (const char* o = &argv[i][1]; *o; ++o) { switch (*o) { - case 's': flag_s = true; break; - case 'n': flag_n = true; break; - case 'r': flag_r = true; break; - case 'm': flag_m = true; break; - case 'a': flag_s = flag_n = flag_r = flag_m = true; break; + case 's': + flag_s = true; + break; + case 'n': + flag_n = true; + break; + case 'r': + flag_r = true; + break; + case 'm': + flag_m = true; + break; + case 'a': + flag_s = flag_n = flag_r = flag_m = true; + break; } } } @@ -43,4 +53,3 @@ int main(int argc, char** argv) printf("\n"); return 0; } - diff --git a/Userland/uptime.cpp b/Userland/uptime.cpp index 4ee6717f6a..4d430589dd 100644 --- a/Userland/uptime.cpp +++ b/Userland/uptime.cpp @@ -19,22 +19,22 @@ int main(int, char**) sscanf(buffer, "%u", &seconds); printf("Up "); - + if (seconds / 86400 > 0) { printf("%d day%s, ", seconds / 86400, (seconds / 86400) == 1 ? "" : "s"); seconds %= 86400; } - + if (seconds / 3600 > 0) { printf("%d hour%s, ", seconds / 3600, (seconds / 3600) == 1 ? "" : "s"); seconds %= 3600; } - + if (seconds / 60 > 0) { printf("%d minute%s, ", seconds / 60, (seconds / 60) == 1 ? "" : "s"); seconds %= 60; } - + printf("%d second%s\n", seconds, seconds == 1 ? "" : "s"); fclose(fp); |