From 3a2171e4061f3a6e3f00c28edf78ff9473355887 Mon Sep 17 00:00:00 2001
From: Damien George <damien.p.george@gmail.com>
Date: Fri, 4 Sep 2015 16:53:46 +0100
Subject: [PATCH] py: Eliminate some cases which trigger unused parameter
 warnings.

---
 py/bc.c           | 4 ++++
 py/emitbc.c       | 3 +++
 py/gc.c           | 6 ++++--
 py/modsys.c       | 1 +
 py/objarray.c     | 2 ++
 py/objenumerate.c | 1 +
 py/objstr.c       | 6 ++++--
 7 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/py/bc.c b/py/bc.c
index a8f256668..3e9125d5c 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -55,8 +55,12 @@ mp_uint_t mp_decode_uint(const byte **ptr) {
 STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, mp_uint_t expected, mp_uint_t given) {
 #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
     // generic message, used also for other argument issues
+    (void)f;
+    (void)expected;
+    (void)given;
     mp_arg_error_terse_mismatch();
 #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
+    (void)f;
     nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError,
         "function takes %d positional arguments but %d were given", expected, given));
 #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
diff --git a/py/emitbc.c b/py/emitbc.c
index 11e65f62e..63e7bc3f9 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -416,6 +416,9 @@ void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) {
         emit->last_source_line_offset = emit->bytecode_offset;
         emit->last_source_line = source_line;
     }
+#else
+    (void)emit;
+    (void)source_line;
 #endif
 }
 
diff --git a/py/gc.c b/py/gc.c
index 7283e5f1f..e4d29d130 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -413,14 +413,16 @@ found:
     // to point to the heap and may prevent other blocks from being reclaimed.
     memset((byte*)ret_ptr + n_bytes, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK - n_bytes);
 
-#if MICROPY_ENABLE_FINALISER
+    #if MICROPY_ENABLE_FINALISER
     if (has_finaliser) {
         // clear type pointer in case it is never set
         ((mp_obj_base_t*)ret_ptr)->type = MP_OBJ_NULL;
         // set mp_obj flag only if it has a finaliser
         FTB_SET(start_block);
     }
-#endif
+    #else
+    (void)has_finaliser;
+    #endif
 
     #if EXTENSIVE_HEAP_PROFILING
     gc_dump_alloc_table();
diff --git a/py/modsys.c b/py/modsys.c
index 73ee320e9..4a0c76fe7 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -114,6 +114,7 @@ STATIC mp_obj_t mp_sys_print_exception(mp_uint_t n_args, const mp_obj_t *args) {
     mp_print_t print = {stream_obj, (mp_print_strn_t)mp_stream_write};
     mp_obj_print_exception(&print, args[0]);
     #else
+    (void)n_args;
     mp_obj_print_exception(&mp_plat_print, args[0]);
     #endif
 
diff --git a/py/objarray.c b/py/objarray.c
index f5ea79404..3f432f00b 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -488,6 +488,8 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
         }
         bufinfo->buf = (uint8_t*)bufinfo->buf + (mp_uint_t)o->free * sz;
     }
+    #else
+    (void)flags;
     #endif
     return 0;
 }
diff --git a/py/objenumerate.c b/py/objenumerate.c
index 36f72083b..9cdd4fda5 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -57,6 +57,7 @@ STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
     o->iter = mp_getiter(vals[0].u_obj);
     o->cur = vals[1].u_int;
 #else
+    (void)n_kw;
     mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
     o->base.type = type_in;
     o->iter = mp_getiter(args[0]);
diff --git a/py/objstr.c b/py/objstr.c
index ed61d17f8..998232249 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -172,11 +172,13 @@ mp_obj_t mp_obj_str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
 STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
     (void)type_in;
 
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     if (n_kw != 0) {
         mp_arg_error_unimpl_kw();
     }
-#endif
+    #else
+    (void)n_kw;
+    #endif
 
     if (n_args == 0) {
         return mp_const_empty_bytes;
-- 
GitLab