Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Allen <[email protected]>
  • Loading branch information
Paul Allen committed Jan 28, 2021
1 parent 84cbb2a commit dd1dd43
Show file tree
Hide file tree
Showing 75 changed files with 217 additions and 319 deletions.
4 changes: 2 additions & 2 deletions ext2/ext2common.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ MYST_INLINE uint32_t ext2_count_bits(uint8_t byte)

uint32_t ext2_count_bits_n(const uint8_t* data, uint32_t size);

MYST_INLINE uint32_t ext2_make_ino(
const ext2_t* ext2, uint32_t grpno, uint32_t lino)
MYST_INLINE uint32_t
ext2_make_ino(const ext2_t* ext2, uint32_t grpno, uint32_t lino)
{
return (grpno * ext2->sb.s_inodes_per_group) + (lino + 1);
}
Expand Down
6 changes: 3 additions & 3 deletions host/blockdevice.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#include <string.h>
#include <stdbool.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>

#include <myst/blockdevice.h>
#include <myst/eraise.h>
Expand Down
2 changes: 1 addition & 1 deletion host/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Licensed under the MIT License.

#include <assert.h>
#include <malloc.h>
#include <myst/elf.h>
#include <myst/eraise.h>
#include <myst/round.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
Expand Down
2 changes: 1 addition & 1 deletion host/loadfssig.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int myst_load_fssig(const char* path, myst_fssig_t* fssig)
myst_fssig_t buf;

if (fssig)
memset(fssig, 0, sizeof (myst_fssig_t));
memset(fssig, 0, sizeof(myst_fssig_t));

if (!path || !fssig)
ERAISE(-EINVAL);
Expand Down
2 changes: 1 addition & 1 deletion include/myst/blkdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#define _MYST_BLKDEV_H

#include <fcntl.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/stat.h>

#define MYST_BLKSIZE 512
Expand Down
5 changes: 2 additions & 3 deletions include/myst/blockdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@
#ifndef _MYST_RAWBLKDEV_H
#define _MYST_RAWBLKDEV_H

#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>

typedef struct myst_block
{
uint8_t data[512];
}
myst_block_t;
} myst_block_t;

int myst_open_block_device(const char* path, bool read_only);

Expand Down
11 changes: 2 additions & 9 deletions include/myst/buf.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ int myst_buf_resize(myst_buf_t* buf, size_t new_size);

int myst_buf_append(myst_buf_t* buf, const void* p, size_t size);

int myst_buf_insert(
myst_buf_t* buf,
size_t pos,
const void* data,
size_t size);
int myst_buf_insert(myst_buf_t* buf, size_t pos, const void* data, size_t size);

int myst_buf_remove(myst_buf_t* buf, size_t pos, size_t size);

Expand All @@ -49,10 +45,7 @@ int myst_buf_pack_str(myst_buf_t* buf, const char* str);

int myst_buf_unpack_str(myst_buf_t* buf, const char** str, size_t* len);

int myst_buf_pack_strings(
myst_buf_t* buf,
const char* strings[],
size_t count);
int myst_buf_pack_strings(myst_buf_t* buf, const char* strings[], size_t count);

int myst_buf_unpack_strings(
myst_buf_t* buf,
Expand Down
8 changes: 3 additions & 5 deletions include/myst/byteorder.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ static __inline__ bool myst_is_big_endian(void)
#if defined(__i386) || defined(__x86_64)
return false;
#else
typedef union un
{
typedef union un {
unsigned short x;
unsigned char bytes[2];
}
un;
static un u = { 0xABCD };
} un;
static un u = {0xABCD};
return u.bytes[0] == 0xAB ? true : false;
#endif
}
Expand Down
10 changes: 5 additions & 5 deletions include/myst/cpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
**==============================================================================
*/

#define MYST_CPIO_MAGIC_INITIALIZER { '0', '7', '0', '7', '0', '1' }
#define MYST_CPIO_MAGIC_INITIALIZER \
{ \
'0', '7', '0', '7', '0', '1' \
}

#define MYST_CPIO_PATH_MAX 256

Expand Down Expand Up @@ -77,10 +80,7 @@ ssize_t myst_cpio_read_data(myst_cpio_t* cpio, void* data, size_t size);

int myst_cpio_write_entry(myst_cpio_t* cpio, const myst_cpio_entry_t* entry);

ssize_t myst_cpio_write_data(
myst_cpio_t* cpio,
const void* data,
size_t size);
ssize_t myst_cpio_write_data(myst_cpio_t* cpio, const void* data, size_t size);

int myst_cpio_pack(const char* source, const char* target);

Expand Down
40 changes: 18 additions & 22 deletions include/myst/eraise.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
#include <stdint.h>
#include <stdio.h>

#define ERAISE(ERRNUM) \
do \
{ \
ret = ERRNUM; \
if (ret < 0) \
{ \
#define ERAISE(ERRNUM) \
do \
{ \
ret = ERRNUM; \
if (ret < 0) \
{ \
myst_eraise(__FILE__, __LINE__, __FUNCTION__, (int)ret); \
goto done; \
} \
goto done; \
} \
} while (0)

#define ECHECK(ERRNUM) \
do \
{ \
typeof(ERRNUM) _r_ = ERRNUM; \
if (_r_ < 0) \
{ \
ret = (typeof(ret))_r_; \
#define ECHECK(ERRNUM) \
do \
{ \
typeof(ERRNUM) _r_ = ERRNUM; \
if (_r_ < 0) \
{ \
ret = (typeof(ret))_r_; \
myst_eraise(__FILE__, __LINE__, __FUNCTION__, (int)ret); \
goto done; \
} \
goto done; \
} \
} while (0)

#define ECHECK_QUIET(ERRNUM) \
Expand All @@ -48,10 +48,6 @@
goto done; \
} while (0)

void myst_eraise(
const char* file,
uint32_t line,
const char* func,
int errnum);
void myst_eraise(const char* file, uint32_t line, const char* func, int errnum);

#endif /* _MYST_ERAISE_H */
6 changes: 1 addition & 5 deletions include/myst/ext2.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,7 @@ int ext2_open(
mode_t mode,
myst_file_t** file);

int64_t ext2_read(
myst_fs_t* fs,
myst_file_t* file,
void* data,
uint64_t size);
int64_t ext2_read(myst_fs_t* fs, myst_file_t* file, void* data, uint64_t size);

int64_t ext2_write(
myst_fs_t* fs,
Expand Down
6 changes: 2 additions & 4 deletions include/myst/fdtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
#include <myst/defs.h>
#include <myst/epolldev.h>
#include <myst/fs.h>
#include <myst/inotifydev.h>
#include <myst/pipedev.h>
#include <myst/sockdev.h>
#include <myst/spinlock.h>
#include <myst/ttydev.h>
#include <myst/inotifydev.h>

#define MYST_FDTABLE_SIZE 1024

Expand Down Expand Up @@ -152,9 +152,7 @@ int myst_fdtable_get_any(
/* get the fdtable for the current thread */
myst_fdtable_t* myst_fdtable_current(void);

int myst_fdtable_clone(
myst_fdtable_t* fdtable,
myst_fdtable_t** fdtable_out);
int myst_fdtable_clone(myst_fdtable_t* fdtable, myst_fdtable_t** fdtable_out);

MYST_INLINE bool myst_valid_fd(int fd)
{
Expand Down
14 changes: 4 additions & 10 deletions include/myst/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ struct myst_fs
mode_t mode,
myst_file_t** file);

off_t (*fs_lseek)(
myst_fs_t* fs,
myst_file_t* file,
off_t offset,
int whence);
off_t (
*fs_lseek)(myst_fs_t* fs, myst_file_t* file, off_t offset, int whence);

ssize_t (
*fs_read)(myst_fs_t* fs, myst_file_t* file, void* buf, size_t count);
Expand Down Expand Up @@ -117,11 +114,8 @@ struct myst_fs

int (*fs_symlink)(myst_fs_t* fs, const char* target, const char* linkpath);

int (*fs_realpath)(
myst_fs_t* fs,
myst_file_t* file,
char* buf,
size_t size);
int (
*fs_realpath)(myst_fs_t* fs, myst_file_t* file, char* buf, size_t size);

int (*fs_fcntl)(myst_fs_t* fs, myst_file_t* file, int cmd, long arg);

Expand Down
5 changes: 2 additions & 3 deletions include/myst/fssig.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
#ifndef _MYST_FSSIG_H
#define _MYST_FSSIG_H

#include <stdint.h>
#include <myst/defs.h>
#include <myst/sha256.h>
#include <stdint.h>

#define MYST_FSSIG_MAGIC 0xf55198a153624d38

Expand Down Expand Up @@ -41,8 +41,7 @@ typedef struct myst_fssig

/* padding */
uint8_t padding[2976];
}
myst_fssig_t;
} myst_fssig_t;

MYST_STATIC_ASSERT(sizeof(myst_fssig_t) == 4096);

Expand Down
10 changes: 5 additions & 5 deletions include/myst/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ typedef struct _json_parser_options
} json_parser_options_t;

typedef void (*json_trace_t)(
json_parser_t* parser,
const char* file,
unsigned int line,
const char* func,
const char* message);
json_parser_t* parser,
const char* file,
unsigned int line,
const char* func,
const char* message);

struct _json_parser
{
Expand Down
4 changes: 1 addition & 3 deletions include/myst/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ MYST_INLINE void myst_list_remove(myst_list_t* list, myst_list_node_t* node)
list->size--;
}

MYST_INLINE void myst_list_prepend(
myst_list_t* list,
myst_list_node_t* node)
MYST_INLINE void myst_list_prepend(myst_list_t* list, myst_list_node_t* node)
{
if (list->head)
{
Expand Down
7 changes: 2 additions & 5 deletions include/myst/mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#ifndef _MYST_MOUNT_H
#define _MYST_MOUNT_H

#include <myst/fs.h>
#include <limits.h>
#include <myst/fs.h>

/* Mount a file system onto a target path */
int myst_mount(myst_fs_t* fs, const char* target);
Expand All @@ -14,9 +14,6 @@ int myst_mount(myst_fs_t* fs, const char* target);
int myst_umount(const char* target);

/* Use mounter to resolve this path to a target path */
int myst_mount_resolve(
const char* path,
char suffix[PATH_MAX],
myst_fs_t** fs);
int myst_mount_resolve(const char* path, char suffix[PATH_MAX], myst_fs_t** fs);

#endif /* _MYST_MOUNT_H */
3 changes: 1 addition & 2 deletions include/myst/ref/malloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ typedef struct myst_malloc_stats
/* only works with MYST_ENABLE_LEAK_CHECKER flags. Returns -ENOTSUP */
int myst_get_malloc_stats(myst_malloc_stats_t* stats);

#define myst_malloc(size) \
__myst_malloc(size, __FILE__, __LINE__, __FUNCTION__)
#define myst_malloc(size) __myst_malloc(size, __FILE__, __LINE__, __FUNCTION__)

#define myst_calloc(nmemb, size) \
__myst_calloc(nmemb, size, __FILE__, __LINE__, __FUNCTION__)
Expand Down
6 changes: 2 additions & 4 deletions include/myst/sha256.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@
typedef struct myst_sha256_ctx
{
uint64_t opaque[16];
}
myst_sha256_ctx_t;
} myst_sha256_ctx_t;

typedef struct myst_sha256
{
uint8_t data[MYST_SHA256_SIZE];
}
myst_sha256_t;
} myst_sha256_t;

int myst_sha256(myst_sha256_t* sha256, const void* data, size_t size);

Expand Down
6 changes: 2 additions & 4 deletions include/myst/sockdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ struct myst_sockdev
const struct iovec* iov,
int iovcnt);

int (*sd_fstat)(
myst_sockdev_t* sd,
myst_sock_t* sock,
struct stat* statbuf);
int (
*sd_fstat)(myst_sockdev_t* sd, myst_sock_t* sock, struct stat* statbuf);

int (*sd_ioctl)(
myst_sockdev_t* sd,
Expand Down
2 changes: 1 addition & 1 deletion include/myst/tcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <time.h>
#include <unistd.h>

#include <myst/defs.h>
#include <myst/blockdevice.h>
#include <myst/defs.h>
#include <myst/fssig.h>

typedef enum myst_tcall_number
Expand Down
8 changes: 4 additions & 4 deletions include/myst/times.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ clock_getcpuclockid: pid -> (-pid-1)*8U + 2
pthread_getcpuclockid: tid -> (-tid-1)*8U + 6;
Order of operations:
1. negate pid or tid
2. subtract 1
3. mul 8
4. add 2(pid) or 6(tid)
1. negate pid or tid
2. subtract 1
3. mul 8
4. add 2(pid) or 6(tid)
Steps 1-3. differentiate these clockids from real id clocks.
Step 4 differentiates thread clocks from process clocks.
Expand Down
Loading

0 comments on commit dd1dd43

Please sign in to comment.