Skip to content

Commit

Permalink
LibC: 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 892acfb commit 46527b7
Show file tree
Hide file tree
Showing 40 changed files with 165 additions and 218 deletions.
4 changes: 2 additions & 2 deletions LibC/SharedBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <AK/kmalloc.h>
#include <LibC/SharedBuffer.h>
#include <unistd.h>
#include <stdio.h>
#include <AK/kmalloc.h>
#include <unistd.h>

RetainPtr<SharedBuffer> SharedBuffer::create(pid_t peer, int size)
{
Expand Down
4 changes: 1 addition & 3 deletions LibC/arpa/inet.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <errno.h>

extern "C" {

Expand Down Expand Up @@ -56,6 +56,4 @@ in_addr_t inet_addr(const char* str)
return INADDR_NONE;
return tmp;
}

}

6 changes: 3 additions & 3 deletions LibC/assert.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

extern "C" {
Expand All @@ -11,8 +11,8 @@ void __assertion_failed(const char* msg, const char* file, unsigned line, const
dbgprintf("USERSPACE(%d) ASSERTION FAILED: %s\n%s:%u in %s\n", getpid(), msg, file, line, func);
fprintf(stderr, "ASSERTION FAILED: %s\n%s:%u in %s\n", msg, file, line, func);
abort();
for (;;);
for (;;)
;
}
#endif

}
1 change: 0 additions & 1 deletion LibC/crt0.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,4 @@ int _start(int argc, char** argv, char** env)
void __cxa_atexit()
{
}

}
9 changes: 4 additions & 5 deletions LibC/ctype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ extern "C" {

const char _ctype_[256] = {
_C, _C, _C, _C, _C, _C, _C, _C,
_C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
_C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C,
_C, _C, _C, _C, _C, _C, _C, _C,
_C, _C, _C, _C, _C, _C, _C, _C,
(char)(_S|_B), _P, _P, _P, _P, _P, _P, _P,
(char)(_S | _B), _P, _P, _P, _P, _P, _P, _P,
_P, _P, _P, _P, _P, _P, _P, _P,
_N, _N, _N, _N, _N, _N, _N, _N,
_N, _N, _P, _P, _P, _P, _P, _P,
_P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
_P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U,
_U, _U, _U, _U, _U, _U, _U, _U,
_U, _U, _U, _U, _U, _U, _U, _U,
_U, _U, _U, _P, _P, _P, _P, _P,
_P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
_P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L,
_L, _L, _L, _L, _L, _L, _L, _L,
_L, _L, _L, _L, _L, _L, _L, _L,
_L, _L, _L, _P, _P, _P, _P, _C
Expand All @@ -35,5 +35,4 @@ int toupper(int c)
return c & ~0x20;
return c;
}

}
6 changes: 2 additions & 4 deletions LibC/dirent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>

extern "C" {

Expand Down Expand Up @@ -39,7 +38,8 @@ int closedir(DIR* dirp)
return rc;
}

struct [[gnu::packed]] sys_dirent {
struct [[gnu::packed]] sys_dirent
{
ino_t ino;
byte file_type;
size_t namelen;
Expand Down Expand Up @@ -91,6 +91,4 @@ int dirfd(DIR* dirp)
ASSERT(dirp);
return dirp->fd;
}

}

7 changes: 3 additions & 4 deletions LibC/dlfcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@ int dlclose(void*)
ASSERT_NOT_REACHED();
}

char *dlerror()
char* dlerror()
{
ASSERT_NOT_REACHED();
}

void *dlopen(const char*, int)
void* dlopen(const char*, int)
{
ASSERT_NOT_REACHED();
}

void *dlsym(void*, const char*)
void* dlsym(void*, const char*)
{
ASSERT_NOT_REACHED();
}

}
3 changes: 1 addition & 2 deletions LibC/fcntl.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <Kernel/Syscall.h>

extern "C" {

Expand All @@ -14,5 +14,4 @@ int fcntl(int fd, int cmd, ...)
int rc = syscall(SC_fcntl, fd, cmd, extra_arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

}
20 changes: 9 additions & 11 deletions LibC/getopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,20 @@
#include <string.h>
#include <unistd.h>

int opterr = 1; /* if error message should be printed */
int opterr = 1; /* if error message should be printed */
int optind = 1; /* index into parent argv vector */
int optopt; /* character checked for validity */
int optreset; /* reset getopt */
char *optarg; /* argument associated with option */
char* optarg; /* argument associated with option */

#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""
#define BADCH (int)'?'
#define BADARG (int)':'
#define EMSG ""

int getopt(int nargc, char* const nargv[], const char* ostr)
{
static const char* place = EMSG; /* option letter processing */
char *oli; /* option letter list index */
char* oli; /* option letter list index */

ASSERT(nargv != NULL);
ASSERT(ostr != NULL);
Expand All @@ -70,7 +70,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
place = EMSG;
return -1;
}
} /* option letter okay? */
} /* option letter okay? */
if ((optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, optopt))) {
/*
* if the user didn't specify '-' as an option,
Expand All @@ -88,8 +88,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
optarg = NULL;
if (!*place)
++optind;
}
else { /* need an argument */
} else { /* need an argument */
if (*place) /* no white space */
optarg = const_cast<char*>(place);
else if (nargc <= ++optind) { /* no arg */
Expand All @@ -99,8 +98,7 @@ int getopt(int nargc, char* const nargv[], const char* ostr)
if (opterr)
fprintf(stderr, "option requires an argument -- %c\n", optopt);
return BADCH;
}
else /* white space */
} else /* white space */
optarg = nargv[optind];
place = EMSG;
++optind;
Expand Down
5 changes: 2 additions & 3 deletions LibC/grp.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <AK/AKString.h>
#include <grp.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <AK/AKString.h>
#include <unistd.h>

extern "C" {

Expand Down Expand Up @@ -138,5 +138,4 @@ int initgroups(const char* user, gid_t extra_gid)
gids[count++] = extra_gid;
return setgroups(count, gids);
}

}
4 changes: 1 addition & 3 deletions LibC/ioctl.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <Kernel/Syscall.h>

extern "C" {

Expand All @@ -14,6 +14,4 @@ int ioctl(int fd, unsigned request, ...)
int rc = syscall(SC_ioctl, fd, request, arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

}

3 changes: 1 addition & 2 deletions LibC/locale.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <locale.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>

extern "C" {
Expand All @@ -20,5 +20,4 @@ struct lconv* localeconv()
{
return &default_locale;
}

}
14 changes: 6 additions & 8 deletions LibC/malloc.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#include <AK/Bitmap.h>
#include <AK/InlineLinkedList.h>
#include <AK/Vector.h>
#include <sys/mman.h>
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <serenity.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/mman.h>

// FIXME: Thread safety.

Expand All @@ -16,7 +16,7 @@
#define FREE_SCRUB_BYTE 0x82
#define MAGIC_PAGE_HEADER 0x42657274
#define MAGIC_BIGALLOC_HEADER 0x42697267
#define PAGE_ROUND_UP(x) ((((size_t)(x)) + PAGE_SIZE-1) & (~(PAGE_SIZE-1)))
#define PAGE_ROUND_UP(x) ((((size_t)(x)) + PAGE_SIZE - 1) & (~(PAGE_SIZE - 1)))

static const size_t number_of_chunked_blocks_to_keep_around_per_size_class = 32;
static const size_t number_of_big_blocks_to_keep_around_per_size_class = 8;
Expand Down Expand Up @@ -45,7 +45,8 @@ struct FreelistEntry {
FreelistEntry* next;
};

struct ChunkedBlock : public CommonHeader, public InlineLinkedListNode<ChunkedBlock> {
struct ChunkedBlock : public CommonHeader
, public InlineLinkedListNode<ChunkedBlock> {
ChunkedBlock(size_t bytes_per_chunk)
{
m_magic = MAGIC_PAGE_HEADER;
Expand All @@ -59,7 +60,6 @@ struct ChunkedBlock : public CommonHeader, public InlineLinkedListNode<ChunkedBl
else
entry->next = nullptr;
}

}

ChunkedBlock* m_prev { nullptr };
Expand Down Expand Up @@ -309,6 +309,4 @@ void __malloc_init()
if (getenv("LIBC_LOG_MALLOC"))
s_log_malloc = true;
}

}

5 changes: 2 additions & 3 deletions LibC/mman.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <mman.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <mman.h>
#include <stdio.h>
#include <Kernel/Syscall.h>

extern "C" {

Expand Down Expand Up @@ -50,5 +50,4 @@ int shm_unlink(const char* name)
int rc = syscall(SC_unlink, name);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

}
4 changes: 1 addition & 3 deletions LibC/mntent.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <mntent.h>
#include <assert.h>
#include <mntent.h>

extern "C" {

Expand All @@ -8,6 +8,4 @@ struct mntent* getmntent(FILE*)
ASSERT_NOT_REACHED();
return nullptr;
}

}

4 changes: 1 addition & 3 deletions LibC/poll.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <poll.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <poll.h>

extern "C" {

Expand All @@ -9,6 +9,4 @@ int poll(struct pollfd* fds, int nfds, int timeout)
int rc = syscall(SC_poll, fds, nfds, timeout);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

}

5 changes: 2 additions & 3 deletions LibC/pwd.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <AK/AKString.h>
#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mman.h>
#include <AK/AKString.h>
#include <unistd.h>

extern "C" {

Expand Down Expand Up @@ -125,5 +125,4 @@ struct passwd* getpwent()
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), PWDB_STR_MAX_LEN);
return __pwdb_entry;
}

}
Loading

0 comments on commit 46527b7

Please sign in to comment.