Skip to content

Commit

Permalink
Userland: Run clang-format on everything.
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jun 7, 2019
1 parent f7ede14 commit b07bbf3
Show file tree
Hide file tree
Showing 48 changed files with 260 additions and 257 deletions.
4 changes: 2 additions & 2 deletions Userland/al.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <unistd.h>

static volatile bool got_alarm = false;

Expand All @@ -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");
Expand Down
10 changes: 5 additions & 5 deletions Userland/cat.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
6 changes: 3 additions & 3 deletions Userland/chmod.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
8 changes: 4 additions & 4 deletions Userland/chown.cpp
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
1 change: 0 additions & 1 deletion Userland/clear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ int main(int, char**)
fflush(stdout);
return 0;
}

10 changes: 5 additions & 5 deletions Userland/cp.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
8 changes: 7 additions & 1 deletion Userland/crash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions Userland/date.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <time.h>
#include <stdio.h>
#include <string.h>
#include <time.h>

int main(int argc, char** argv)
{
Expand All @@ -21,4 +21,3 @@ int main(int argc, char** argv)
tm->tm_sec);
return 0;
}

8 changes: 4 additions & 4 deletions Userland/df.cpp
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
10 changes: 5 additions & 5 deletions Userland/dmesg.cpp
Original file line number Diff line number Diff line change
@@ -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());
Expand Down
2 changes: 1 addition & 1 deletion Userland/env.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <unistd.h>
#include <stdio.h>
#include <unistd.h>

int main(int, char**)
{
Expand Down
2 changes: 1 addition & 1 deletion Userland/fgrep.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
40 changes: 20 additions & 20 deletions Userland/guitest2.cpp
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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();
};

Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Userland/head.cpp
Original file line number Diff line number Diff line change
@@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions Userland/host.cpp
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down
9 changes: 4 additions & 5 deletions Userland/hostname.cpp
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -16,4 +16,3 @@ int main(int argc, char** argv)
printf("%s\n", buffer);
return 0;
}

13 changes: 6 additions & 7 deletions Userland/id.cpp
Original file line number Diff line number Diff line change
@@ -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();

Expand Down Expand Up @@ -40,4 +40,3 @@ int main(int argc, char** argv)
printf("\n");
return 0;
}

7 changes: 3 additions & 4 deletions Userland/kill.cpp
Original file line number Diff line number Diff line change
@@ -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()
{
Expand Down Expand Up @@ -38,4 +38,3 @@ int main(int argc, char** argv)
perror("kill");
return 0;
}

22 changes: 11 additions & 11 deletions Userland/killall.cpp
Original file line number Diff line number Diff line change
@@ -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()
{
Expand All @@ -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;
}

Expand All @@ -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]);
Expand Down
Loading

0 comments on commit b07bbf3

Please sign in to comment.