1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:27:43 +00:00

LibC: Run clang-format on everything.

This commit is contained in:
Andreas Kling 2019-06-07 11:49:03 +02:00
parent 892acfb10d
commit 46527b72d7
40 changed files with 181 additions and 234 deletions

View file

@ -1,7 +1,7 @@
#include <LibC/SharedBuffer.h>
#include <unistd.h>
#include <stdio.h>
#include <AK/kmalloc.h>
#include <LibC/SharedBuffer.h>
#include <stdio.h>
#include <unistd.h>
RetainPtr<SharedBuffer> SharedBuffer::create(pid_t peer, int size)
{

View file

@ -1,7 +1,7 @@
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/in.h>
#include <stdio.h>
#include <errno.h>
extern "C" {
@ -56,6 +56,4 @@ in_addr_t inet_addr(const char* str)
return INADDR_NONE;
return tmp;
}
}

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
extern "C" {
@ -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
}

View file

@ -51,5 +51,4 @@ int _start(int argc, char** argv, char** env)
void __cxa_atexit()
{
}
}

View file

@ -35,5 +35,4 @@ int toupper(int c)
return c & ~0x20;
return c;
}
}

View file

@ -9,7 +9,6 @@
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <unistd.h>
extern "C" {
@ -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;
@ -91,6 +91,4 @@ int dirfd(DIR* dirp)
ASSERT(dirp);
return dirp->fd;
}
}

View file

@ -22,5 +22,4 @@ void *dlsym(void*, const char*)
{
ASSERT_NOT_REACHED();
}
}

View file

@ -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" {
@ -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);
}
}

View file

@ -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 */
@ -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;

View file

@ -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" {
@ -138,5 +138,4 @@ int initgroups(const char* user, gid_t extra_gid)
gids[count++] = extra_gid;
return setgroups(count, gids);
}
}

View file

@ -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" {
@ -14,6 +14,4 @@ int ioctl(int fd, unsigned request, ...)
int rc = syscall(SC_ioctl, fd, request, arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,5 +1,5 @@
#include <locale.h>
#include <assert.h>
#include <locale.h>
#include <stdio.h>
extern "C" {
@ -20,5 +20,4 @@ struct lconv* localeconv()
{
return &default_locale;
}
}

View file

@ -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.
@ -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;
@ -59,7 +60,6 @@ struct ChunkedBlock : public CommonHeader, public InlineLinkedListNode<ChunkedBl
else
entry->next = nullptr;
}
}
ChunkedBlock* m_prev { nullptr };
@ -309,6 +309,4 @@ void __malloc_init()
if (getenv("LIBC_LOG_MALLOC"))
s_log_malloc = true;
}
}

View file

@ -1,7 +1,7 @@
#include <mman.h>
#include <errno.h>
#include <stdio.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <mman.h>
#include <stdio.h>
extern "C" {
@ -50,5 +50,4 @@ int shm_unlink(const char* name)
int rc = syscall(SC_unlink, name);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,5 +1,5 @@
#include <mntent.h>
#include <assert.h>
#include <mntent.h>
extern "C" {
@ -8,6 +8,4 @@ struct mntent* getmntent(FILE*)
ASSERT_NOT_REACHED();
return nullptr;
}
}

View file

@ -1,6 +1,6 @@
#include <poll.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <poll.h>
extern "C" {
@ -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);
}
}

View file

@ -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" {
@ -125,5 +125,4 @@ next_entry:
strncpy(__pwdb_entry->shell_buffer, e_shell.characters(), PWDB_STR_MAX_LEN);
return __pwdb_entry;
}
}

View file

@ -35,8 +35,8 @@
static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
#include <stdlib.h>
#include <sys/types.h>
static void insertion_sort(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
static void insertion_sort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const void*, const void*, void*), void* arg);
@ -64,7 +64,8 @@ void insertion_sort(void* bot, size_t nmemb, size_t size, int (*compar)(const vo
char *s1, *s2, *t1, *t2, *top;
top = (char*)bot + nmemb * size;
for (t1 = (char*)bot + size; t1 < top;) {
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;);
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2) < 0;)
;
if (t1 != (t2 += size)) {
for (cnt = size; cnt--; ++t1) {
ch = *t1;
@ -84,7 +85,8 @@ void insertion_sort_r(void* bot, size_t nmemb, size_t size, int (*compar)(const
char *s1, *s2, *t1, *t2, *top;
top = (char*)bot + nmemb * size;
for (t1 = (char*)bot + size; t1 < top;) {
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2, arg) < 0;);
for (t2 = t1; (t2 -= size) >= bot && compar(t1, t2, arg) < 0;)
;
if (t1 != (t2 += size)) {
for (cnt = size; cnt--; ++t1) {
ch = *t1;

View file

@ -28,10 +28,10 @@
* SUCH DAMAGE.
*
*/
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
static const char* determine_base(const char* p, int& base)
{
@ -140,7 +140,8 @@ int vsscanf(const char *buf, const char *s, va_list ap)
noassign = true;
else if (*s >= '1' && *s <= '9') {
const char* tc;
for (tc = s; isdigit(*s); s++);
for (tc = s; isdigit(*s); s++)
;
strncpy(tmp, tc, s - tc);
tmp[s - tc] = '\0';
atob((uint32_t*)&width, tmp, 10);

View file

@ -1,6 +1,6 @@
#include <sched.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sched.h>
extern "C" {
@ -33,6 +33,4 @@ int sched_getparam(pid_t pid, struct sched_param *param)
int rc = syscall(SC_sched_getparam, pid, param);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,7 +1,7 @@
#pragma once
#include <sys/types.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS

View file

@ -1,10 +1,10 @@
#include <unistd.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <setjmp.h>
#include <assert.h>
#include <Kernel/Syscall.h>
#include <unistd.h>
extern "C" {
@ -160,5 +160,4 @@ int sigsuspend(const sigset_t*)
dbgprintf("FIXME: Implement sigsuspend()\n");
ASSERT_NOT_REACHED();
}
}

View file

@ -1,8 +1,8 @@
#include <sys/stat.h>
#include <errno.h>
#include <assert.h>
#include <stdio.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <stdio.h>
#include <sys/stat.h>
extern "C" {
@ -28,6 +28,4 @@ int fchmod(int fd, mode_t mode)
int rc = syscall(SC_fchmod, fd, mode);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -11,7 +11,6 @@
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include <unistd.h>
extern "C" {
@ -573,6 +572,4 @@ FILE* tmpfile()
dbgprintf("FIXME: Implement tmpfile()\n");
ASSERT_NOT_REACHED();
}
}

View file

@ -41,7 +41,6 @@ int atexit(void (*handler)())
return 0;
}
void abort()
{
raise(SIGABRT);
@ -347,8 +346,7 @@ long strtol(const char* str, char** endptr, int base)
c = *s++;
} else if (c == '+')
c = *s++;
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
if ((base == 0 || base == 16) && c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
@ -392,5 +390,4 @@ unsigned long strtoul(const char* str, char** endptr, int base)
ASSERT(value >= 0);
return value;
}
}

View file

@ -1,12 +1,12 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include <assert.h>
#include <stdlib.h>
#include <AK/Types.h>
#include <AK/StdLibExtras.h>
#include "ctype.h"
#include <AK/StdLibExtras.h>
#include <AK/Types.h>
#include <assert.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
extern "C" {
@ -146,17 +146,14 @@ void* memcpy(void* dest_ptr, const void* src_ptr, size_t n)
"rep movsl\n"
: "=S"(src), "=D"(dest)
: "S"(src), "D"(dest), "c"(dwords)
: "memory"
);
: "memory");
n -= dwords * sizeof(dword);
if (n == 0)
return dest_ptr;
}
asm volatile(
"rep movsb\n"
:: "S"(src), "D"(dest), "c"(n)
: "memory"
);
"rep movsb\n" ::"S"(src), "D"(dest), "c"(n)
: "memory");
return dest_ptr;
}
@ -173,8 +170,7 @@ void* memset(void* dest_ptr, int c, size_t n)
"rep stosl\n"
: "=D"(dest)
: "D"(dest), "c"(dwords), "a"(expanded_c)
: "memory"
);
: "memory");
n -= dwords * sizeof(dword);
if (n == 0)
return dest_ptr;
@ -183,12 +179,10 @@ void* memset(void* dest_ptr, int c, size_t n)
"rep stosb\n"
: "=D"(dest), "=c"(n)
: "0"(dest), "1"(n), "a"(c)
: "memory"
);
: "memory");
return dest_ptr;
}
void* memmove(void* dest, const void* src, size_t n)
{
if (dest < src)
@ -204,7 +198,8 @@ void* memmove(void* dest, const void* src, size_t n)
char* strcpy(char* dest, const char* src)
{
char* originalDest = dest;
while ((*dest++ = *src++) != '\0');
while ((*dest++ = *src++) != '\0')
;
return originalDest;
}
@ -413,6 +408,4 @@ size_t strxfrm(char* dest, const char* src, size_t n)
dest[i] = '\0';
return i;
}
}

View file

@ -1,6 +1,6 @@
#include <strings.h>
#include <assert.h>
#include <ctype.h>
#include <strings.h>
extern "C" {
@ -32,5 +32,4 @@ int strncasecmp(const char* s1, const char* s2, size_t n)
} while (--n);
return 0;
}
}

View file

@ -1,7 +1,7 @@
#include <sys/select.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdio.h>
#include <sys/select.h>
extern "C" {
@ -11,5 +11,4 @@ int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struc
int rc = syscall(SC_select, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,8 +1,8 @@
#include <sys/socket.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <AK/Assertions.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdio.h>
#include <sys/socket.h>
extern "C" {
@ -85,5 +85,4 @@ int getpeername(int sockfd, struct sockaddr* addr, socklen_t* addrlen)
int rc = syscall(SC_getpeername, sockfd, addr, addrlen);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <sys/uio.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/uio.h>
extern "C" {
@ -9,5 +9,4 @@ ssize_t writev(int fd, const struct iovec* iov, int iov_count)
int rc = syscall(SC_writev, fd, iov, iov_count);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <assert.h>
#include <sys/wait.h>
#include <unistd.h>
#include <assert.h>
extern "C" {
@ -8,5 +8,4 @@ pid_t wait(int* wstatus)
{
return waitpid(-1, wstatus, 0);
}
}

View file

@ -1,9 +1,9 @@
#include <termcap.h>
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <AK/HashMap.h>
#include <AK/AKString.h>
#include <AK/HashMap.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <termcap.h>
//#define TERMCAP_DEBUG
@ -126,6 +126,4 @@ int tputs(const char* str, int affcnt, int (*putc)(int))
putc(str[i]);
return 0;
}
}

View file

@ -1,8 +1,8 @@
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <Kernel/Syscall.h>
#include <termios.h>
extern "C" {
@ -48,6 +48,4 @@ speed_t cfgetospeed(const struct termios* tp)
{
return tp->c_ospeed;
}
}

View file

@ -1,9 +1,9 @@
#include <time.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/times.h>
#include <errno.h>
#include <assert.h>
#include <Kernel/Syscall.h>
#include <time.h>
extern "C" {
@ -117,5 +117,4 @@ clock_t clock()
times(&tms);
return tms.tms_utime + tms.tms_stime;
}
}

View file

@ -1,6 +1,6 @@
#include <sys/times.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/times.h>
clock_t times(struct tms* buf)
{

View file

@ -1,5 +1,5 @@
#include <ulimit.h>
#include <assert.h>
#include <ulimit.h>
extern "C" {
@ -9,5 +9,4 @@ long ulimit(int cmd, long newlimit)
(void)newlimit;
ASSERT_NOT_REACHED();
}
}

View file

@ -1,18 +1,18 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <AK/AKString.h>
#include <AK/Vector.h>
#include <Kernel/Syscall.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <Kernel/Syscall.h>
#include <AK/Vector.h>
#include <AK/AKString.h>
#include <unistd.h>
extern "C" {
@ -492,5 +492,4 @@ int fsync(int fd)
dbgprintf("FIXME: Implement fsync()\n");
return 0;
}
}

View file

@ -1,6 +1,6 @@
#include <utime.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <utime.h>
extern "C" {
@ -9,6 +9,4 @@ int utime(const char* pathname, const struct utimbuf* buf)
int rc = syscall(SC_utime, (dword)pathname, (dword)buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -1,6 +1,6 @@
#include <sys/utsname.h>
#include <errno.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <sys/utsname.h>
extern "C" {
@ -9,6 +9,4 @@ int uname(struct utsname* buf)
int rc = syscall(SC_uname, buf);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}