diff --git a/Userland/al.cpp b/Userland/al.cpp index d5b2cad0fdf377..96094d5d6ce2cb 100644 --- a/Userland/al.cpp +++ b/Userland/al.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include 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 4b86ea9a14eb5a..e03801487d3679 100644 --- a/Userland/cat.cpp +++ b/Userland/cat.cpp @@ -1,10 +1,10 @@ -#include -#include +#include #include -#include -#include #include -#include +#include +#include +#include +#include int main(int argc, char** argv) { diff --git a/Userland/chmod.cpp b/Userland/chmod.cpp index 496762226da128..e4057af0c0908f 100644 --- a/Userland/chmod.cpp +++ b/Userland/chmod.cpp @@ -1,9 +1,9 @@ -#include -#include #include #include +#include +#include -int main(int argc, char **argv) +int main(int argc, char** argv) { if (argc != 3) { printf("usage: chmod \n"); diff --git a/Userland/chown.cpp b/Userland/chown.cpp index e5b2be2a3696b9..256e82e81fbac6 100644 --- a/Userland/chown.cpp +++ b/Userland/chown.cpp @@ -1,10 +1,10 @@ -#include -#include +#include #include #include -#include +#include +#include -int main(int argc, char **argv) +int main(int argc, char** argv) { if (argc < 2) { printf("usage: chown \n"); diff --git a/Userland/clear.cpp b/Userland/clear.cpp index e31f99328bbeb9..6cdedc3ec756be 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 bfc263e0aac147..03e3e0411c4ab8 100644 --- a/Userland/cp.cpp +++ b/Userland/cp.cpp @@ -1,11 +1,11 @@ -#include -#include +#include +#include +#include #include +#include #include #include -#include -#include -#include +#include int main(int argc, char** argv) { diff --git a/Userland/crash.cpp b/Userland/crash.cpp index f19b714d6d2d8b..ddef7531e9986f 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 d280a7434f9c3f..90edd680c458df 100644 --- a/Userland/date.cpp +++ b/Userland/date.cpp @@ -1,6 +1,6 @@ -#include #include #include +#include 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 62572921aab976..875aaa0d11546e 100644 --- a/Userland/df.cpp +++ b/Userland/df.cpp @@ -1,9 +1,9 @@ -#include -#include -#include -#include #include #include +#include +#include +#include +#include struct FileSystem { String fs; diff --git a/Userland/dmesg.cpp b/Userland/dmesg.cpp index f8b3b48db1ad8f..bc558815fc6bb5 100644 --- a/Userland/dmesg.cpp +++ b/Userland/dmesg.cpp @@ -1,13 +1,13 @@ +#include +#include +#include #include #include -#include -#include -#include 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 0a2a0e39d54fe5..dc1e8b26dbe97e 100644 --- a/Userland/env.cpp +++ b/Userland/env.cpp @@ -1,5 +1,5 @@ -#include #include +#include int main(int, char**) { diff --git a/Userland/fgrep.cpp b/Userland/fgrep.cpp index 8916d1131a57e4..c24c3fa76a44ce 100644 --- a/Userland/fgrep.cpp +++ b/Userland/fgrep.cpp @@ -1,7 +1,7 @@ +#include #include #include #include -#include int main(int argc, char** argv) { diff --git a/Userland/guitest2.cpp b/Userland/guitest2.cpp index 79c229c8f8fbd3..21ce0fd2a59ddc 100644 --- a/Userland/guitest2.cpp +++ b/Userland/guitest2.cpp @@ -1,24 +1,24 @@ -#include -#include -#include -#include -#include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include +#include #include +#include #include +#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include +#include +#include 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 49ae45ab183a91..e43e0eca91d0c8 100644 --- a/Userland/head.cpp +++ b/Userland/head.cpp @@ -1,7 +1,7 @@ +#include #include #include #include -#include 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 52e307ad9ba2ac..74f1a0c822a07a 100644 --- a/Userland/host.cpp +++ b/Userland/host.cpp @@ -1,8 +1,8 @@ -#include #include +#include #include -#include #include +#include int main(int argc, char** argv) { diff --git a/Userland/hostname.cpp b/Userland/hostname.cpp index 4589da8a5caa9e..d343b5b55ef57c 100644 --- a/Userland/hostname.cpp +++ b/Userland/hostname.cpp @@ -1,12 +1,12 @@ -#include -#include #include +#include #include +#include 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 9c4a0f24cb86c5..b552f6a52895ac 100644 --- a/Userland/id.cpp +++ b/Userland/id.cpp @@ -1,15 +1,15 @@ -#include -#include -#include -#include #include +#include +#include +#include +#include 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 7b1cb9a1d10faf..3a01d4f7eb0881 100644 --- a/Userland/kill.cpp +++ b/Userland/kill.cpp @@ -1,8 +1,8 @@ -#include -#include +#include #include +#include #include -#include +#include 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 11413511a910b4..85594d8ea8fd77 100644 --- a/Userland/killall.cpp +++ b/Userland/killall.cpp @@ -1,9 +1,9 @@ -#include -#include +#include +#include #include +#include #include -#include -#include +#include 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 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 9e6a7c1021757f..54cf0d40d50981 100644 --- a/Userland/ln.cpp +++ b/Userland/ln.cpp @@ -1,8 +1,8 @@ -#include +#include #include -#include +#include #include -#include +#include 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 b8d92f058e42ec..f5655ac6a55251 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -1,18 +1,18 @@ -#include -#include +#include +#include +#include #include #include -#include -#include -#include #include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include 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 c370a1486bdd86..9bfe50b2bc7d76 100644 --- a/Userland/mkdir.cpp +++ b/Userland/mkdir.cpp @@ -1,10 +1,10 @@ -#include -#include +#include #include -#include +#include #include -#include +#include #include +#include int main(int argc, char** argv) { diff --git a/Userland/mknod.cpp b/Userland/mknod.cpp index dc1221b51d7ad0..113aac17028241 100644 --- a/Userland/mknod.cpp +++ b/Userland/mknod.cpp @@ -1,7 +1,7 @@ -#include #include #include #include +#include inline constexpr unsigned encoded_device(unsigned major, unsigned minor) { diff --git a/Userland/mm.cpp b/Userland/mm.cpp index 2a79a555358e3d..e9b734121c9bde 100644 --- a/Userland/mm.cpp +++ b/Userland/mm.cpp @@ -1,12 +1,12 @@ +#include +#include #include #include -#include -#include 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 d0050c6b9dd0b9..6371ef01f44065 100644 --- a/Userland/more.cpp +++ b/Userland/more.cpp @@ -1,7 +1,7 @@ -#include -#include #include +#include #include +#include 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 486761c00e9e44..6edf589de345e5 100644 --- a/Userland/mv.cpp +++ b/Userland/mv.cpp @@ -1,8 +1,8 @@ -#include -#include -#include #include #include +#include +#include +#include int main(int argc, char** argv) { diff --git a/Userland/pape.cpp b/Userland/pape.cpp index 138b98642d885e..b77584165d9e55 100644 --- a/Userland/pape.cpp +++ b/Userland/pape.cpp @@ -1,18 +1,18 @@ -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include -#include #include #include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include 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 09ce327ff1abe4..ea2cb4c57a47d1 100644 --- a/Userland/pidof.cpp +++ b/Userland/pidof.cpp @@ -1,21 +1,21 @@ -#include -#include -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include +#include +#include +#include static int pid_of(const String& process_name, bool single_shot, bool omit_pid, pid_t pid) { bool displayed_at_least_one = false; HashMap 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 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 05a63d0b66535a..9151c0df726fea 100644 --- a/Userland/ping.cpp +++ b/Userland/ping.cpp @@ -1,17 +1,17 @@ -#include -#include #include -#include +#include #include +#include #include #include -#include -#include +#include +#include #include +#include 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 4fd0c4aa0a295b..2485b36057f817 100644 --- a/Userland/ps.cpp +++ b/Userland/ps.cpp @@ -1,12 +1,12 @@ +#include +#include #include #include -#include -#include 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 e3b5c49cb9d401..f3ab074af9d533 100644 --- a/Userland/qs.cpp +++ b/Userland/qs.cpp @@ -1,11 +1,11 @@ -#include +#include #include -#include -#include #include -#include +#include #include -#include +#include +#include +#include #include int main(int argc, char** argv) @@ -15,7 +15,7 @@ int main(int argc, char** argv) auto menubar = make(); auto app_menu = make("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("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 8d84f8cc67015b..8d802139b68244 100644 --- a/Userland/rmdir.cpp +++ b/Userland/rmdir.cpp @@ -1,5 +1,5 @@ -#include #include +#include #include 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 25aa3732f817fd..a91001cc40f905 100644 --- a/Userland/sleep.cpp +++ b/Userland/sleep.cpp @@ -1,7 +1,7 @@ -#include -#include -#include #include +#include +#include +#include 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 35d3933f9e2f8c..543a1185c3cac8 100644 --- a/Userland/sort.cpp +++ b/Userland/sort.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include #include #include @@ -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 fc6154f07474b1..cab32139b98eb0 100644 --- a/Userland/stat.cpp +++ b/Userland/stat.cpp @@ -1,9 +1,9 @@ -#include -#include -#include -#include #include +#include +#include #include +#include +#include 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 bd8b9cf61b954e..786479aade2794 100644 --- a/Userland/strace.cpp +++ b/Userland/strace.cpp @@ -1,11 +1,11 @@ -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include static int usage() { diff --git a/Userland/su.cpp b/Userland/su.cpp index 354d97aa76fa3b..8f7a10aa8255af 100644 --- a/Userland/su.cpp +++ b/Userland/su.cpp @@ -1,8 +1,8 @@ -#include -#include -#include -#include #include +#include +#include +#include +#include extern "C" int main(int, char**); diff --git a/Userland/sysctl.cpp b/Userland/sysctl.cpp index 90fead0f2d7d15..29e8c7f76855bb 100644 --- a/Userland/sysctl.cpp +++ b/Userland/sysctl.cpp @@ -1,15 +1,15 @@ -#include -#include -#include -#include -#include -#include #include #include #include #include #include #include +#include +#include +#include +#include +#include +#include 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 values = args.get_single_values(); return handle_var(values[0]); } - diff --git a/Userland/tail.cpp b/Userland/tail.cpp index 8fe43d992a8892..0da99fa91050de 100644 --- a/Userland/tail.cpp +++ b/Userland/tail.cpp @@ -1,11 +1,11 @@ +#include +#include +#include +#include #include -#include #include -#include +#include #include -#include -#include -#include #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 408cbab3fb47da..7abf31c9af5077 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 51b0c053542872..d4bded2dd51309 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 a0c33500491c5b..352947c69a8894 100644 --- a/Userland/top.cpp +++ b/Userland/top.cpp @@ -1,12 +1,12 @@ -#include -#include +#include +#include +#include +#include #include #include +#include #include -#include -#include -#include -#include +#include static HashMap* 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 690e6d86710c5d..8674a5b9497cea 100644 --- a/Userland/touch.cpp +++ b/Userland/touch.cpp @@ -1,11 +1,11 @@ -#include #include -#include #include -#include +#include #include -#include #include +#include +#include +#include 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 c9be4b0f3a4855..36b294318fce6e 100644 --- a/Userland/tr.cpp +++ b/Userland/tr.cpp @@ -1,6 +1,6 @@ +#include #include #include -#include #include #include diff --git a/Userland/tst.cpp b/Userland/tst.cpp index bea9c63e611946..b94ae2e4869d24 100644 --- a/Userland/tst.cpp +++ b/Userland/tst.cpp @@ -1,11 +1,11 @@ #include -#include #include +#include 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 4ef617616e6e29..5fe908ee54401b 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 64e43c3565d7fa..98987e0d409a14 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 4ee6717f6a038b..4d430589dd3567 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);