diff options
| author | emlslxl <[email protected]> | 2017-09-15 11:02:24 +0800 |
|---|---|---|
| committer | emlslxl <[email protected]> | 2017-09-15 11:02:24 +0800 |
| commit | e521decf2eaf88c662fba12b2d9f07b68bd4979c (patch) | |
| tree | fbc869c77c305ec42044ef81f7756076e9ee8936 /src/kservice.c | |
| parent | 0d193254f8600a36b5df604974beccf7491572e2 (diff) | |
根据documentation/coding_style_cn.txt约定 对内核src和include目录下的文件代码进行格式化
Diffstat (limited to 'src/kservice.c')
| -rw-r--r-- | src/kservice.c | 81 |
1 files changed, 41 insertions, 40 deletions
diff --git a/src/kservice.c b/src/kservice.c index 123c852971..c694037dd2 100644 --- a/src/kservice.c +++ b/src/kservice.c @@ -118,7 +118,7 @@ int *_rt_errno(void) tid = rt_thread_self(); if (tid != RT_NULL) - return (int *)&(tid->error); + return (int *) & (tid->error); return (int *)&_errno; } @@ -464,9 +464,9 @@ rt_int32_t rt_strcmp(const char *cs, const char *ct) RTM_EXPORT(rt_strcmp); /** * The strnlen() function returns the number of characters in the - * string pointed to by s, excluding the terminating null byte ('\0'), - * but at most maxlen. In doing this, strnlen() looks only at the - * first maxlen characters in the string pointed to by s and never + * string pointed to by s, excluding the terminating null byte ('\0'), + * but at most maxlen. In doing this, strnlen() looks only at the + * first maxlen characters in the string pointed to by s and never * beyond s+maxlen. * * @param s the string @@ -547,13 +547,13 @@ rt_inline rt_int32_t divide(rt_int32_t *n, rt_int32_t base) /* optimized for processor which does not support divide instructions. */ if (base == 10) { - res = ((rt_uint32_t)*n) % 10U; - *n = ((rt_uint32_t)*n) / 10U; + res = ((rt_uint32_t) * n) % 10U; + *n = ((rt_uint32_t) * n) / 10U; } else { - res = ((rt_uint32_t)*n) % 16U; - *n = ((rt_uint32_t)*n) / 16U; + res = ((rt_uint32_t) * n) % 16U; + *n = ((rt_uint32_t) * n) / 16U; } return res; @@ -561,7 +561,7 @@ rt_inline rt_int32_t divide(rt_int32_t *n, rt_int32_t base) rt_inline int skip_atoi(const char **s) { - register int i=0; + register int i = 0; while (isdigit(**s)) i = i * 10 + *((*s)++) - '0'; @@ -640,7 +640,7 @@ static char *print_number(char *buf, i = 0; if (num == 0) - tmp[i++]='0'; + tmp[i++] = '0'; else { while (num != 0) @@ -655,12 +655,12 @@ static char *print_number(char *buf, size -= i; #endif - if (!(type&(ZEROPAD | LEFT))) + if (!(type & (ZEROPAD | LEFT))) { - if ((sign)&&(size>0)) + if ((sign) && (size > 0)) size--; - while (size-->0) + while (size-- > 0) { if (buf <= end) *buf = ' '; @@ -681,7 +681,7 @@ static char *print_number(char *buf, #ifdef RT_PRINTF_SPECIAL if (type & SPECIAL) { - if (base==8) + if (base == 8) { if (buf <= end) *buf = '0'; @@ -694,7 +694,7 @@ static char *print_number(char *buf, ++ buf; if (buf <= end) { - *buf = type & LARGE? 'X' : 'x'; + *buf = type & LARGE ? 'X' : 'x'; } ++ buf; } @@ -768,7 +768,7 @@ rt_int32_t rt_vsnprintf(char *buf, /* Make sure end is always >= buf */ if (end < buf) { - end = ((char *)-1); + end = ((char *) - 1); size = end - buf; } @@ -929,7 +929,7 @@ rt_int32_t rt_vsnprintf(char *buf, ++ str; continue; - /* integer number formats - set up the flags and "break" */ + /* integer number formats - set up the flags and "break" */ case 'o': base = 8; break; @@ -1028,7 +1028,7 @@ RTM_EXPORT(rt_snprintf); */ rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr) { - return rt_vsnprintf(buf, (rt_size_t) -1, format, arg_ptr); + return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr); } RTM_EXPORT(rt_vsprintf); @@ -1044,7 +1044,7 @@ rt_int32_t rt_sprintf(char *buf, const char *format, ...) va_list arg_ptr; va_start(arg_ptr, format); - n = rt_vsprintf(buf ,format, arg_ptr); + n = rt_vsprintf(buf, format, arg_ptr); va_end(arg_ptr); return n; @@ -1183,7 +1183,7 @@ RTM_EXPORT(rt_kprintf); * * @return the allocated memory block on successful, otherwise returns RT_NULL */ -void* rt_malloc_align(rt_size_t size, rt_size_t align) +void *rt_malloc_align(rt_size_t size, rt_size_t align) { void *align_ptr; void *ptr; @@ -1198,7 +1198,7 @@ void* rt_malloc_align(rt_size_t size, rt_size_t align) ptr = rt_malloc(align_size); if (ptr != RT_NULL) { - /* the allocated memory block is aligned */ + /* the allocated memory block is aligned */ if (((rt_uint32_t)ptr & (align - 1)) == 0) { align_ptr = (void *)((rt_uint32_t)ptr + align); @@ -1228,7 +1228,7 @@ void rt_free_align(void *ptr) { void *real_ptr; - real_ptr = (void *)*(rt_uint32_t *)((rt_uint32_t)ptr - sizeof(void *)); + real_ptr = (void *) * (rt_uint32_t *)((rt_uint32_t)ptr - sizeof(void *)); rt_free(real_ptr); } RTM_EXPORT(rt_free_align); @@ -1284,13 +1284,14 @@ rt_ubase_t __rt_ffs(rt_ubase_t value) #ifdef RT_DEBUG /* RT_ASSERT(EX)'s hook */ -void (*rt_assert_hook)(const char* ex, const char* func, rt_size_t line); +void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line); /** * This function will set a hook function to RT_ASSERT(EX). It will run when the expression is false. * * @param hook the hook function */ -void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t line)) { +void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line)) +{ rt_assert_hook = hook; } @@ -1301,30 +1302,30 @@ void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t * @param func the function name when assertion. * @param line the file line number when assertion. */ -void rt_assert_handler(const char* ex_string, const char* func, rt_size_t line) +void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line) { volatile char dummy = 0; if (rt_assert_hook == RT_NULL) { #ifdef RT_USING_MODULE - if (rt_module_self() != RT_NULL) - { - /* unload assertion module */ - rt_module_unload(rt_module_self()); + if (rt_module_self() != RT_NULL) + { + /* unload assertion module */ + rt_module_unload(rt_module_self()); - /* re-schedule */ - rt_schedule(); - } - else + /* re-schedule */ + rt_schedule(); + } + else #endif - { - rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line); - while (dummy == 0); - } + { + rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line); + while (dummy == 0); + } } - else - { + else + { rt_assert_hook(ex_string, func, line); } } @@ -1339,7 +1340,7 @@ void *memmove(void *dest, const void *src, size_t n) __attribute__((weak, alias( int memcmp(const void *s1, const void *s2, size_t n) __attribute__((weak, alias("rt_memcmp"))); size_t strlen(const char *s) __attribute__((weak, alias("rt_strlen"))); -char *strstr(const char *s1,const char *s2) __attribute__((weak, alias("rt_strstr"))); +char *strstr(const char *s1, const char *s2) __attribute__((weak, alias("rt_strstr"))); int strcasecmp(const char *a, const char *b) __attribute__((weak, alias("rt_strcasecmp"))); char *strncpy(char *dest, const char *src, size_t n) __attribute__((weak, alias("rt_strncpy"))); int strncmp(const char *cs, const char *ct, size_t count) __attribute__((weak, alias("rt_strncmp"))); |
