summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
committermicroDev <70126934+microDev1@users.noreply.github.com>2021-03-15 19:27:36 +0530
commita52eb88031620a81521b937f2a0651dbac2bb350 (patch)
tree017cbf8f686b252241182ef61ce48e8457aa1577 /lib
parent090b6ba42fcdfbb16844f77892087f91aa6ea201 (diff)
run code formatting script
Diffstat (limited to 'lib')
-rw-r--r--lib/netutils/netutils.c2
-rw-r--r--lib/timeutils/timeutils.c10
-rw-r--r--lib/timeutils/timeutils.h18
-rw-r--r--lib/utils/buffer_helper.c4
-rw-r--r--lib/utils/buffer_helper.h2
-rw-r--r--lib/utils/context_manager_helpers.c2
-rw-r--r--lib/utils/printf.c4
-rw-r--r--[-rwxr-xr-x]lib/utils/pyexec.c32
-rw-r--r--lib/utils/pyexec.h2
-rw-r--r--lib/utils/stdout_helpers.c2
-rw-r--r--lib/utils/sys_stdio_mphal.c12
11 files changed, 45 insertions, 45 deletions
diff --git a/lib/netutils/netutils.c b/lib/netutils/netutils.c
index 4385f5a5e..e82ef9270 100644
--- a/lib/netutils/netutils.c
+++ b/lib/netutils/netutils.c
@@ -65,7 +65,7 @@ void netutils_parse_ipv4_addr(mp_obj_t addr_in, uint8_t *out_ip, netutils_endian
}
const char *s = addr_str;
const char *s_top = addr_str + addr_len;
- for (mp_uint_t i = 3 ; ; i--) {
+ for (mp_uint_t i = 3; ; i--) {
mp_uint_t val = 0;
for (; s < s_top && *s != '.'; s++) {
val = val * 10 + *s - '0';
diff --git a/lib/timeutils/timeutils.c b/lib/timeutils/timeutils.c
index fdd3426ad..6cbea31aa 100644
--- a/lib/timeutils/timeutils.c
+++ b/lib/timeutils/timeutils.c
@@ -36,11 +36,11 @@
#define LEAPOCH ((31 + 29) * 86400)
-#define DAYS_PER_400Y (365*400 + 97)
-#define DAYS_PER_100Y (365*100 + 24)
-#define DAYS_PER_4Y (365*4 + 1)
+#define DAYS_PER_400Y (365 * 400 + 97)
+#define DAYS_PER_100Y (365 * 100 + 24)
+#define DAYS_PER_4Y (365 * 4 + 1)
-STATIC const uint16_t days_since_jan1[]= { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
+STATIC const uint16_t days_since_jan1[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 };
bool timeutils_is_leap_year(mp_uint_t year) {
return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
@@ -164,7 +164,7 @@ void timeutils_seconds_since_epoch_to_struct_time(mp_uint_t t, timeutils_struct_
}
mp_uint_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month, mp_uint_t date,
- mp_uint_t hour, mp_uint_t minute, mp_uint_t second) {
+ mp_uint_t hour, mp_uint_t minute, mp_uint_t second) {
mp_uint_t t = timeutils_seconds_since_2000(year, month, date, hour, minute, second);
return t + EPOCH1970_EPOCH2000_DIFF_SECS;
}
diff --git a/lib/timeutils/timeutils.h b/lib/timeutils/timeutils.h
index 4ba8c7fda..168617428 100644
--- a/lib/timeutils/timeutils.h
+++ b/lib/timeutils/timeutils.h
@@ -30,14 +30,14 @@
#define EPOCH1970_EPOCH2000_DIFF_SECS 946684800
typedef struct _timeutils_struct_time_t {
- uint16_t tm_year; // i.e. 2014
- uint8_t tm_mon; // 1..12
- uint8_t tm_mday; // 1..31
- uint8_t tm_hour; // 0..23
- uint8_t tm_min; // 0..59
- uint8_t tm_sec; // 0..59
- uint8_t tm_wday; // 0..6 0 = Monday
- uint16_t tm_yday; // 1..366
+ uint16_t tm_year; // i.e. 2014
+ uint8_t tm_mon; // 1..12
+ uint8_t tm_mday; // 1..31
+ uint8_t tm_hour; // 0..23
+ uint8_t tm_min; // 0..59
+ uint8_t tm_sec; // 0..59
+ uint8_t tm_wday; // 0..6 0 = Monday
+ uint16_t tm_yday; // 1..366
} timeutils_struct_time_t;
bool timeutils_is_leap_year(mp_uint_t year);
@@ -53,7 +53,7 @@ mp_uint_t timeutils_seconds_since_2000(mp_uint_t year, mp_uint_t month,
void timeutils_seconds_since_epoch_to_struct_time(mp_uint_t t, timeutils_struct_time_t *tm);
mp_uint_t timeutils_seconds_since_epoch(mp_uint_t year, mp_uint_t month, mp_uint_t date,
- mp_uint_t hour, mp_uint_t minute, mp_uint_t second);
+ mp_uint_t hour, mp_uint_t minute, mp_uint_t second);
mp_uint_t timeutils_mktime(mp_uint_t year, mp_int_t month, mp_int_t mday,
mp_int_t hours, mp_int_t minutes, mp_int_t seconds);
diff --git a/lib/utils/buffer_helper.c b/lib/utils/buffer_helper.c
index 694952e3d..a4008225d 100644
--- a/lib/utils/buffer_helper.c
+++ b/lib/utils/buffer_helper.c
@@ -26,10 +26,10 @@
#include "lib/utils/buffer_helper.h"
-void normalize_buffer_bounds(int32_t* start, int32_t end, size_t* length) {
+void normalize_buffer_bounds(int32_t *start, int32_t end, size_t *length) {
if (end < 0) {
end += *length;
- } else if (((size_t) end) > *length) {
+ } else if (((size_t)end) > *length) {
end = *length;
}
if (*start < 0) {
diff --git a/lib/utils/buffer_helper.h b/lib/utils/buffer_helper.h
index 7487b9df5..9611dc309 100644
--- a/lib/utils/buffer_helper.h
+++ b/lib/utils/buffer_helper.h
@@ -30,6 +30,6 @@
#include <stdint.h>
#include <string.h>
-void normalize_buffer_bounds(int32_t* start, int32_t end, size_t* length);
+void normalize_buffer_bounds(int32_t *start, int32_t end, size_t *length);
#endif // MICROPY_INCLUDED_LIB_UTILS_BUFFER_HELPER_H
diff --git a/lib/utils/context_manager_helpers.c b/lib/utils/context_manager_helpers.c
index 901c27030..261485616 100644
--- a/lib/utils/context_manager_helpers.c
+++ b/lib/utils/context_manager_helpers.c
@@ -29,6 +29,6 @@
#include "py/obj.h"
STATIC mp_obj_t default___enter__(mp_obj_t self_in) {
- return self_in;
+ return self_in;
}
MP_DEFINE_CONST_FUN_OBJ_1(default___enter___obj, default___enter__);
diff --git a/lib/utils/printf.c b/lib/utils/printf.c
index e95d778fd..859c7e001 100644
--- a/lib/utils/printf.c
+++ b/lib/utils/printf.c
@@ -108,7 +108,7 @@ STATIC void strn_print_strn(void *data, const char *str, size_t len) {
// when linkings against it statically.
// GCC 9 gives a warning about missing attributes so it's excluded until
// uClibc+GCC9 support is needed.
-int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias ("vsnprintf")));
+int __GI_vsnprintf(char *str, size_t size, const char *fmt, va_list ap) __attribute__((weak, alias("vsnprintf")));
#endif
int vsnprintf(char *str, size_t size, const char *fmt, va_list ap) {
@@ -134,4 +134,4 @@ int snprintf(char *str, size_t size, const char *fmt, ...) {
return ret;
}
-#endif //MICROPY_USE_INTERNAL_PRINTF
+#endif // MICROPY_USE_INTERNAL_PRINTF
diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c
index 68a3710ce..450b5ae32 100755..100644
--- a/lib/utils/pyexec.c
+++ b/lib/utils/pyexec.c
@@ -85,7 +85,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
} else if (exec_flags & EXEC_FLAG_SOURCE_IS_FILENAME) {
lex = mp_lexer_new_from_file(source);
} else {
- lex = (mp_lexer_t*)source;
+ lex = (mp_lexer_t *)source;
}
// source is a lexer, parse and compile the script
qstr source_name = lex->source_name;
@@ -95,7 +95,7 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
mp_parse_tree_t parse_tree = mp_parse(lex, input_kind);
module_fun = mp_compile(&parse_tree, source_name, MP_EMIT_OPT_NONE, exec_flags & EXEC_FLAG_IS_REPL);
// Clear the parse tree because it has a heap pointer we don't need anymore.
- *((uint32_t volatile*) &parse_tree.chunk) = 0;
+ *((uint32_t volatile *)&parse_tree.chunk) = 0;
#else
mp_raise_msg(&mp_type_RuntimeError, translate("script compilation not supported"));
#endif
@@ -132,12 +132,12 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_SystemExit)) {
// at the moment, the value of SystemExit is unused
ret = pyexec_system_exit;
-#if CIRCUITPY_ALARM
+ #if CIRCUITPY_ALARM
} else if (mp_obj_is_subclass_fast(mp_obj_get_type((mp_obj_t)nlr.ret_val), &mp_type_DeepSleepRequest)) {
ret = PYEXEC_DEEP_SLEEP;
-#endif
+ #endif
} else {
- if ((mp_obj_t) nlr.ret_val != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
+ if ((mp_obj_t)nlr.ret_val != MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_reload_exception))) {
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
}
ret = PYEXEC_EXCEPTION;
@@ -169,8 +169,8 @@ STATIC int parse_compile_execute(const void *source, mp_parse_input_kind_t input
size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes;
qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes);
printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n "
- "n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n",
- (unsigned)n_pool, (unsigned)n_qstr, (unsigned)n_str_data_bytes, (unsigned)n_total_bytes);
+ "n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n",
+ (unsigned)n_pool, (unsigned)n_qstr, (unsigned)n_str_data_bytes, (unsigned)n_total_bytes);
}
#if MICROPY_ENABLE_GC
@@ -195,7 +195,7 @@ typedef struct _repl_t {
// but it was moved to MP_STATE_VM(repl_line) as containing
// root pointer. Still keep structure in case more state
// will be added later.
- //vstr_t line;
+ // vstr_t line;
bool cont_line;
} repl_t;
@@ -307,10 +307,10 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
} else {
if (ret == CHAR_CTRL_C) {
- // cancel everything
- mp_hal_stdout_tx_str("\r\n");
- repl.cont_line = false;
- goto input_restart;
+ // cancel everything
+ mp_hal_stdout_tx_str("\r\n");
+ repl.cont_line = false;
+ goto input_restart;
} else if (ret == CHAR_CTRL_D) {
// stop entering compound statement
goto exec;
@@ -326,13 +326,13 @@ STATIC int pyexec_friendly_repl_process_char(int c) {
return 0;
}
-exec: ;
+ exec:;
int ret = parse_compile_execute(MP_STATE_VM(repl_line), MP_PARSE_SINGLE_INPUT, EXEC_FLAG_ALLOW_DEBUGGING | EXEC_FLAG_IS_REPL | EXEC_FLAG_SOURCE_IS_VSTR, NULL);
if (ret & PYEXEC_FORCED_EXIT) {
return ret;
}
-input_restart:
+ input_restart:
vstr_reset(MP_STATE_VM(repl_line));
repl.cont_line = false;
readline_init(MP_STATE_VM(repl_line), ">>> ");
@@ -409,11 +409,11 @@ int pyexec_friendly_repl(void) {
vstr_t line;
vstr_init(&line, 32);
-#if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
+ #if defined(USE_HOST_MODE) && MICROPY_HW_HAS_LCD
// in host mode, we enable the LCD for the repl
mp_obj_t lcd_o = mp_call_function_0(mp_load_name(qstr_from_str("LCD")));
mp_call_function_1(mp_load_attr(lcd_o, qstr_from_str("light")), mp_const_true);
-#endif
+ #endif
friendly_repl_reset:
mp_hal_stdout_tx_str("\r\n");
diff --git a/lib/utils/pyexec.h b/lib/utils/pyexec.h
index 4c773cd64..bde2960c2 100644
--- a/lib/utils/pyexec.h
+++ b/lib/utils/pyexec.h
@@ -35,7 +35,7 @@ typedef enum {
typedef struct {
int return_code;
- const mp_obj_type_t * exception_type;
+ const mp_obj_type_t *exception_type;
int exception_line;
} pyexec_result_t;
diff --git a/lib/utils/stdout_helpers.c b/lib/utils/stdout_helpers.c
index 4323e8a08..500b9748b 100644
--- a/lib/utils/stdout_helpers.c
+++ b/lib/utils/stdout_helpers.c
@@ -20,7 +20,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, size_t len) {
i = 1;
}
// Lump all characters on the next line together.
- while((last_cr || str[i] != '\n') && i < len) {
+ while ((last_cr || str[i] != '\n') && i < len) {
last_cr = str[i] == '\r';
i++;
}
diff --git a/lib/utils/sys_stdio_mphal.c b/lib/utils/sys_stdio_mphal.c
index 3a11fa66c..e2e1999c2 100644
--- a/lib/utils/sys_stdio_mphal.c
+++ b/lib/utils/sys_stdio_mphal.c
@@ -65,7 +65,7 @@ STATIC mp_uint_t stdio_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *er
if (c == '\r') {
c = '\n';
}
- ((byte*)buf)[i] = c;
+ ((byte *)buf)[i] = c;
}
return size;
} else {
@@ -87,7 +87,7 @@ STATIC mp_uint_t stdio_write(mp_obj_t self_in, const void *buf, mp_uint_t size,
STATIC mp_uint_t stdio_ioctl(mp_obj_t self_in, mp_uint_t request, uintptr_t arg, int *errcode) {
sys_stdio_obj_t *self = MP_OBJ_TO_PTR(self_in);
- (void) self;
+ (void)self;
// For now, pretend we actually flush the stdio stream.
if (request == MP_STREAM_FLUSH) {
@@ -106,9 +106,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_o
// TODO gc hook to close the file if not already closed
STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = {
-#if MICROPY_PY_SYS_STDIO_BUFFER
+ #if MICROPY_PY_SYS_STDIO_BUFFER
{ MP_ROM_QSTR(MP_QSTR_buffer), MP_ROM_PTR(&stdio_buffer_obj) },
-#endif
+ #endif
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj)},
@@ -138,7 +138,7 @@ STATIC const mp_obj_type_t stdio_obj_type = {
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,
.protocol = &stdio_obj_stream_p,
- .locals_dict = (mp_obj_dict_t*)&stdio_locals_dict,
+ .locals_dict = (mp_obj_dict_t *)&stdio_locals_dict,
};
const sys_stdio_obj_t mp_sys_stdin_obj = {{&stdio_obj_type}, .fd = STDIO_FD_IN};
@@ -148,7 +148,7 @@ const sys_stdio_obj_t mp_sys_stderr_obj = {{&stdio_obj_type}, .fd = STDIO_FD_ERR
#if MICROPY_PY_SYS_STDIO_BUFFER
STATIC mp_uint_t stdio_buffer_read(mp_obj_t self_in, void *buf, mp_uint_t size, int *errcode) {
for (uint i = 0; i < size; i++) {
- ((byte*)buf)[i] = mp_hal_stdin_rx_chr();
+ ((byte *)buf)[i] = mp_hal_stdin_rx_chr();
}
return size;
}