From c6318c079dbfe51157d827341bd390d7e7f2b6a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Sat, 4 Apr 2015 23:29:27 +0200 Subject: [PATCH] Re-format code to avoid overly long lines and declarations --- include/ucore/clock.h | 6 +++--- include/ucore/htable.h | 3 ++- include/ucore/logging.h | 18 +++++++++++++----- include/ucore/mbuf.h | 3 ++- include/ucore/restart_counter.h | 3 +-- include/ucore/string.h | 12 +++++++++--- include/ucore/threadqueue.h | 26 +++++++++++++++++++------- include/ucore/ticket_lock.h | 4 +++- include/ucore/timers.h | 19 +++++++++++-------- src/heapsort.c | 4 ++-- src/hex.c | 5 ++++- src/logging.c | 5 ++++- src/mbuf.c | 6 +++++- src/restart_counter.c | 3 +-- src/supervisor.c | 15 ++++++++++----- src/threadqueue.c | 4 ++-- src/ticket_lock.c | 4 +++- 17 files changed, 94 insertions(+), 46 deletions(-) diff --git a/include/ucore/clock.h b/include/ucore/clock.h index 26aba2e..1f0ea52 100644 --- a/include/ucore/clock.h +++ b/include/ucore/clock.h @@ -82,7 +82,7 @@ extern struct UCoreClock uc_time_clock; * */ void uc_cached_clock_init(struct UCoreCachedClock *uclock, - struct UCoreClock *real_clock); + struct UCoreClock *real_clock); /** Update the cached clock from the real_clock */ @@ -103,7 +103,7 @@ void uc_settable_clock_init(struct UCoreSettableClock *uclock); * @param tv new timeval to set the clock to **/ void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock, - const struct timeval *tv); + const struct timeval *tv); /** * Set the new time this clock will return @@ -114,7 +114,7 @@ void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock, * @param usecs microseconds portion of the clock to set. **/ void uc_settable_clock_set(struct UCoreSettableClock *uclock, - time_t secs, suseconds_t usecs); + time_t secs, suseconds_t usecs); #ifdef __cplusplus } diff --git a/include/ucore/htable.h b/include/ucore/htable.h index 46e4168..5d9fa2c 100644 --- a/include/ucore/htable.h +++ b/include/ucore/htable.h @@ -73,7 +73,8 @@ static inline size_t uc_htable_bucket(const struct UHTable *table, size_t hash) * @param table table * @param hash hash */ -static inline struct UHNode *uc_htable_first_bucket(const struct UHTable *table, size_t hash) +static inline struct UHNode *uc_htable_first_bucket(const struct UHTable *table, + size_t hash) { size_t bucket = uc_htable_bucket(table, hash); diff --git a/include/ucore/logging.h b/include/ucore/logging.h index b7800ed..21402f4 100644 --- a/include/ucore/logging.h +++ b/include/ucore/logging.h @@ -171,7 +171,8 @@ const char *uc_ll_2_str(enum UC_LOG_LEVEL l); * @return An opaque uc_log_destination that can be added as a destination to * the ucore logging system */ -struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_location); +struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, + int log_location); /* creates a new uc_log_destination for logging to syslog * @@ -184,7 +185,10 @@ struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_ * @return An opaque uc_log_destination that can be added as a destination to * the ucore logging system */ -struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum UC_LOG_LEVEL log_level, int log_location); +struct UCLogDestination *uc_log_new_syslog(const char *ident, + int facility, + enum UC_LOG_LEVEL log_level, + int log_location); /* creates a new uc_log_destination for printing on stderr. * @@ -195,7 +199,9 @@ struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum * @param return An opaque uc_log_destination that can be added as a destination to * the ucore logging system */ -struct UCLogDestination *uc_log_new_file(const char *filename, enum UC_LOG_LEVEL log_level, int log_location); +struct UCLogDestination *uc_log_new_file(const char *filename, + enum UC_LOG_LEVEL log_level, + int log_location); /** Add a uc_log_destination to the logging system. * @@ -216,7 +222,8 @@ void uc_log_remove_destination(struct UCLogDestination *dest); * @param dest destination for which to set the log level * @param level The new log level */ -void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_LEVEL level); +void uc_log_destination_set_loglevel(struct UCLogDestination *dest, + enum UC_LOG_LEVEL level); /** Change whether to log the location (file/line no.) of logging * output on a destination, @@ -224,7 +231,8 @@ void uc_log_destination_set_loglevel(struct UCLogDestination *dest, enum UC_LOG_ * @param dest log destination to change * @param log_location 1=log the locaton, 0=don't log the location */ -void uc_log_destination_set_log_location(struct UCLogDestination *dest, int log_location); +void uc_log_destination_set_log_location(struct UCLogDestination *dest, + int log_location); /** Sets the log rotation settings. * Does nothing if the destination is not a UC_LDEST_FILE, or the policy is invalid. diff --git a/include/ucore/mbuf.h b/include/ucore/mbuf.h index f6a1767..704cbe6 100644 --- a/include/ucore/mbuf.h +++ b/include/ucore/mbuf.h @@ -127,7 +127,8 @@ struct MBuf *uc_mbuf_copy_data(struct MBuf *mbuf); * @param headroom the headroom in the buffer * @param flags The appropriate UC_MBUF_FLAGS */ -void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, uint32_t headroom, uint32_t flags); +void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, + uint32_t headroom, uint32_t flags); /** Zero out all the data in this mbuf, including the headroom * diff --git a/include/ucore/restart_counter.h b/include/ucore/restart_counter.h index 806251e..502931f 100644 --- a/include/ucore/restart_counter.h +++ b/include/ucore/restart_counter.h @@ -54,8 +54,7 @@ typedef enum { * @param filename the filename to use to keep track of the state * @param flags one of UC_RC_FL_XX */ -UCRCResult uc_restart_counter_init( - struct UCRestartCounter *counter, +UCRCResult uc_restart_counter_init(struct UCRestartCounter *counter, const char *filename, unsigned int flags); diff --git a/include/ucore/string.h b/include/ucore/string.h index f1269fb..ccdb53d 100644 --- a/include/ucore/string.h +++ b/include/ucore/string.h @@ -36,7 +36,9 @@ uint8_t* uc_hex_decode(const char *restrict in, size_t maxlen,uint8_t *restrict /** As uc_hex_encode , but inserts the @delim string between each converted * byte (each 2 hex chars) */ -char* uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, char *restrict out, int outlen, const char *restrict delim); +char* uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, + char *restrict out, int outlen, + const char *restrict delim); /** * Convert the string to lowercase, calls tolower() on each char. @@ -67,7 +69,9 @@ void uc_str_toupper(char *s); * if the number of ASCII digits is odd. This would usually be 0x0 or 0xf. * @return the number of bytes written to bcdout */ -size_t uc_ascii2bcd(const char *restrict ascii, unsigned char *restrict bcdout, unsigned char filler); +size_t uc_ascii2bcd(const char *restrict ascii, + unsigned char *restrict bcdout, + unsigned char filler); /** Convert the BCD digits to ascii. * The resulting ascii string is 0 terminated. @@ -77,7 +81,9 @@ size_t uc_ascii2bcd(const char *restrict ascii, unsigned char *restrict bcdout, * @param asciiout buffer to place ASCII in, must be UC_ASCII_LEN(bcdlen)+1 big * @return the number of characters written to bcdout (this will always be UC_ASCII_LEN(bcdlen) */ -size_t uc_bcd2ascii(const unsigned char *restrict bcd, size_t bcdlen, char *restrict asciiout); +size_t uc_bcd2ascii(const unsigned char *restrict bcd, + size_t bcdlen, + char *restrict asciiout); /** uc_sprintb for converting the values into ascii bit representation * e.g. 0x3 -> "00000011". The result must be able to hold the max number diff --git a/include/ucore/threadqueue.h b/include/ucore/threadqueue.h index a85932f..9fd60fd 100644 --- a/include/ucore/threadqueue.h +++ b/include/ucore/threadqueue.h @@ -174,13 +174,16 @@ int uc_thread_queue_init(struct uc_threadqueue *queue, unsigned int max_elements * @return 0 on succes ENOMEM if out of memory EINVAL if queue is NULL, ETIMEDOUT if timeout occured or other * errno values if pthread functions failed. */ -int uc_thread_queue_tryadd(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg *msg); +int uc_thread_queue_tryadd(struct uc_threadqueue *queue, + const struct timespec *timeout, + struct uc_threadmsg *msg); /** * Like uc_thread_queue_add but will wait indefintly. * @see uc_thread_queue_add */ -static inline int uc_thread_queue_add(struct uc_threadqueue *queue, struct uc_threadmsg *msg) +static inline int uc_thread_queue_add(struct uc_threadqueue *queue, + struct uc_threadmsg *msg) { return uc_thread_queue_tryadd(queue, NULL, msg); } @@ -207,14 +210,17 @@ static inline int uc_thread_queue_add(struct uc_threadqueue *queue, struct uc_th * * @return 0 on success EINVAL if queue is NULL ETIMEDOUT if timeout occurs */ -int uc_thread_queue_tryget(struct uc_threadqueue *queue, const struct timespec *timeout, struct uc_threadmsg **msg); +int uc_thread_queue_tryget(struct uc_threadqueue *queue, + const struct timespec *timeout, + struct uc_threadmsg **msg); /** * Like uc_thread_queue_tryget, but will wait indefintly for an item * to become available * @see uc_thread_queue_tryget */ -static inline int uc_thread_queue_get(struct uc_threadqueue *queue, struct uc_threadmsg **msg) +static inline int uc_thread_queue_get(struct uc_threadqueue *queue, + struct uc_threadmsg **msg) { return uc_thread_queue_tryget(queue, NULL, msg); } @@ -246,7 +252,9 @@ unsigned int uc_thread_queue_length( struct uc_threadqueue *queue ); * @param cookie pointer passed back to the uc_thread_queue_walk_func * @return 0 on success EINVAL if queue is NULL EBUSY if someone is holding any locks on the queue */ -int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie); +int uc_thread_queue_destroy(struct uc_threadqueue *queue, + uc_thread_queue_walk_func free_func, + void *cookie); /** * Walk the elements of the queue, intended for debugging @@ -261,7 +269,9 @@ int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_f * The function must not in anyway interact with the queue. * @return 0 on success */ -int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func, void *cookie); +int uc_thread_queue_walk(struct uc_threadqueue *queue, + uc_thread_queue_walk_func walk_func, + void *cookie); /** @@ -275,7 +285,9 @@ int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func * @param cookie pointer passed back to the uc_thread_queue_walk_func * @return 0 on success */ -int uc_thread_queue_clear(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie); +int uc_thread_queue_clear(struct uc_threadqueue *queue, + uc_thread_queue_walk_func free_func, + void *cookie); /** diff --git a/include/ucore/ticket_lock.h b/include/ucore/ticket_lock.h index f68c0a2..c7beb5a 100644 --- a/include/ucore/ticket_lock.h +++ b/include/ucore/ticket_lock.h @@ -32,7 +32,9 @@ int uc_ticket_lock_init(struct UCTicketLock *lock); * * @return 0 on success, errno value on failure */ -int uc_ticket_lock_init_ex(struct UCTicketLock *lock, pthread_mutexattr_t *mattr, pthread_condattr_t *cattr); +int uc_ticket_lock_init_ex(struct UCTicketLock *lock, + pthread_mutexattr_t *mattr, + pthread_condattr_t *cattr); /** Acquire the lock */ diff --git a/include/ucore/timers.h b/include/ucore/timers.h index ecdd2e0..4385298 100644 --- a/include/ucore/timers.h +++ b/include/ucore/timers.h @@ -46,8 +46,9 @@ typedef void (*uc_timer_cb)(struct UCTimers *timers, struct UCTimer *timer); struct UCTimer { //Internal members RBNode rb_node; //the RBNode will hold a data pointer to the - //the UCTimer it's a member of. We might get rid of that member, and use CONTAINER_OF - //to find the UCTimer from a RBNode (Or just cast it, it's the 1. member..) + //the UCTimer it's a member of. We might get rid of that + //member, and use CONTAINER_OF to find the UCTimer from + //a RBNode (Or just cast it, it's the 1. member..) //absolute time when the timer should be fired struct timeval timeout; @@ -73,7 +74,8 @@ struct UCTimers { RBTree timer_tree; struct UCoreClock *uclock; size_t seq; //used to generate unique timers - TAILQ_HEAD(, UCTimer) ready_list; //pending timers to be fired while inside uc_timers_run + TAILQ_HEAD(, UCTimer) ready_list; //pending timers to be fired while + //inside uc_timers_run }; /** Initialize a timer engine for use. @@ -103,8 +105,8 @@ void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock); void uc_timers_add(struct UCTimers *timers, struct UCTimer *timer, int sec, int usec); /** Remove a timer. - * Note, the timer memory must have been zeroed out or the timer must have been added at least once - * before uc_timers_remove can be called on a UCTimer. + * Note, the timer memory must have been zeroed out or the timer must have been + * added at least once before uc_timers_remove can be called on a UCTimer. * uc_timers_remove does nothing if the timer has expired. * * @param timers timer engine to remove from @@ -131,7 +133,8 @@ size_t uc_timers_count(const struct UCTimers *timers); /** Check if a timer is running (i.e. hasn't expired and fired) * * @param timer timer to query - * @return 0 if the timer has expired (or was never added) non-0 if it's running (active or pending) + * @return 0 if the timer has expired (or was never added) non-0 if it's + * running (active or pending) */ int uc_timer_running(const struct UCTimer *timer); @@ -141,8 +144,8 @@ int uc_timer_running(const struct UCTimer *timer); * @param timers timer engine to run * @param now The curent time. The engine will fire all timers whose expiry time is * prior to this value. - * @return the number of timers fired, or negative if an error occured(presently no errors - * are possible and the return value is always >= 0 + * @return the number of timers fired, or negative if an error occured(presently + * no errors are possible and the return value is always >= 0 **/ int uc_timers_run(struct UCTimers *timers); diff --git a/src/heapsort.c b/src/heapsort.c index 45a56e5..25c65f1 100644 --- a/src/heapsort.c +++ b/src/heapsort.c @@ -3,7 +3,7 @@ static void uc_sift(unsigned char *base, size_t start, size_t count, size_t width, - uc_hs_cmp cmp, uc_hs_swp swap, void *cookie) +i uc_hs_cmp cmp, uc_hs_swp swap, void *cookie) { size_t root = start, child; @@ -27,7 +27,7 @@ uc_sift(unsigned char *base, size_t start, size_t count, size_t width, void uc_heapsort(void *base_, size_t count, size_t width, - uc_hs_cmp cmp, uc_hs_swp swap, void *cookie) + uc_hs_cmp cmp, uc_hs_swp swap, void *cookie) { long start; long end; diff --git a/src/hex.c b/src/hex.c index 1b01ad9..24d2b1f 100644 --- a/src/hex.c +++ b/src/hex.c @@ -28,7 +28,10 @@ uc_hex_encode(const uint8_t *restrict in, size_t len, char *restrict out) } char* -uc_hex_encode_delim(const uint8_t *restrict in, size_t inlen, char *restrict out, int outlen, const char *restrict delim) +uc_hex_encode_delim( + const uint8_t *restrict in, size_t inlen, + char *restrict out, int outlen, + const char *restrict delim) { size_t i; char *outp = out; diff --git a/src/logging.c b/src/logging.c index 301f5e5..fa716d7 100644 --- a/src/logging.c +++ b/src/logging.c @@ -198,7 +198,10 @@ struct UCLogDestination *uc_log_new_stderr(enum UC_LOG_LEVEL log_level, int log_ return dest; } -struct UCLogDestination *uc_log_new_syslog(const char *ident, int facility, enum UC_LOG_LEVEL log_level, int log_location) +struct UCLogDestination *uc_log_new_syslog(const char *ident, + int facility, + enum UC_LOG_LEVEL log_level, + int log_location) { struct UCLogDestination *dest = calloc(1, sizeof *dest); char *id; diff --git a/src/mbuf.c b/src/mbuf.c index b4ab023..7fa8abc 100644 --- a/src/mbuf.c +++ b/src/mbuf.c @@ -40,7 +40,11 @@ uint8_t *uc_mbuf_pull(struct MBuf *mbuf, uint32_t size) return data; } -void uc_mbuf_init(struct MBuf *mbuf, uint8_t *restrict buf, uint32_t len, uint32_t headroom, uint32_t flags) +void uc_mbuf_init(struct MBuf *mbuf, + uint8_t *restrict buf, + uint32_t len, + uint32_t headroom, + uint32_t flags) { mbuf->bufstart = buf; mbuf->p1 = mbuf->p2 = mbuf->p3 = mbuf->p4 = NULL; diff --git a/src/restart_counter.c b/src/restart_counter.c index b785844..b70c1d7 100644 --- a/src/restart_counter.c +++ b/src/restart_counter.c @@ -20,8 +20,7 @@ static UCRCResult uc_restart_counter_lock(int fd) return UC_RC_OK; } -UCRCResult uc_restart_counter_init( - struct UCRestartCounter *counter, +UCRCResult uc_restart_counter_init(struct UCRestartCounter *counter, const char *filename, unsigned int flags) { diff --git a/src/supervisor.c b/src/supervisor.c index 783ef7a..5efa924 100644 --- a/src/supervisor.c +++ b/src/supervisor.c @@ -66,18 +66,22 @@ again: } if (WIFSIGNALED(status)) { - syslog(LOG_ERR, "supervised process(pid %ld) exited cause of signal %d, status = 0x%X", (long)pid, WTERMSIG(status), status); + syslog(LOG_ERR, "supervised process(pid %ld) exited cause of signal %d, status = 0x%X", + (long)pid, WTERMSIG(status), status); return RESTART; } else if (WIFEXITED(status)) { - syslog(LOG_ERR, "supervised process(pid %ld) exited with code %d, status = 0x%X", (long)pid, WTERMSIG(status), status); + syslog(LOG_ERR, "supervised process(pid %ld) exited with code %d, status = 0x%X", + (long)pid, WTERMSIG(status), status); return RESTART; } /* Ok, can we ever get here ? */ - syslog(LOG_ERR, "waitpid of supervised process(pid %ld) status = 0x%X", (long)pid, status); + syslog(LOG_ERR, "waitpid of supervised process(pid %ld) status = 0x%X", + (long)pid, status); if (kill(pid, 0) == 0) { - syslog(LOG_ERR, "supervised process(pid %ld) seems to still be alive, not restarting", (long)pid); + syslog(LOG_ERR, "supervised process(pid %ld) seems to still be alive, not restarting", + (long)pid); goto again; } @@ -134,7 +138,8 @@ int uc_supervise(void) switch (cmd) { case CLEAN_EXIT: - syslog(LOG_INFO, "Terminating supervised pid %lu", (unsigned long)pid); + syslog(LOG_INFO, "Terminating supervised pid %lu", + (unsigned long)pid); kill_supervised_process(pid); wait(NULL); syslog(LOG_INFO, "Exiting"); diff --git a/src/threadqueue.c b/src/threadqueue.c index 32d01c3..95fe07e 100644 --- a/src/threadqueue.c +++ b/src/threadqueue.c @@ -281,8 +281,8 @@ unsigned int uc_thread_queue_length(struct uc_threadqueue *queue) } int uc_thread_queue_clear(struct uc_threadqueue *queue, - uc_thread_queue_walk_func free_func, - void *cookie) + uc_thread_queue_walk_func free_func, + void *cookie) { if (queue == NULL) { return EINVAL; diff --git a/src/ticket_lock.c b/src/ticket_lock.c index a5d5bfa..a58ab1f 100644 --- a/src/ticket_lock.c +++ b/src/ticket_lock.c @@ -13,7 +13,9 @@ int uc_ticket_lock_init(struct UCTicketLock *lock) return uc_ticket_lock_init_ex(lock, NULL, NULL); } -int uc_ticket_lock_init_ex(struct UCTicketLock *lock, pthread_mutexattr_t *mattr, pthread_condattr_t *cattr) +int uc_ticket_lock_init_ex(struct UCTicketLock *lock, + pthread_mutexattr_t *mattr, + pthread_condattr_t *cattr) { int rc; lock->queue_head = 0;