summaryrefslogtreecommitdiff
path: root/py/binary.c
diff options
context:
space:
mode:
authorJeff Epler <jeff@adafruit.com>2020-09-13 21:28:51 -0500
committerGitHub <noreply@github.com>2020-09-13 21:28:51 -0500
commit814339abb952cd17da8f31c273315eaf9d075c43 (patch)
tree58809a519c393b33bfb864b7c208e6372683b16e /py/binary.c
parent9409a2c34cc27c048f97f79948de43713c8078a0 (diff)
parentb3bdd4686bd5f4a7c91972b9b0f65e624a7eab95 (diff)
Merge pull request #3405 from jepler/implicit-fallthrough-diagnostic
Enable implicit fallthrough diagnostic, note intentional fallthroughs.
Diffstat (limited to 'py/binary.c')
-rw-r--r--py/binary.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/py/binary.c b/py/binary.c
index cd0f1aa4d..b85edba62 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -126,7 +126,6 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
break;
case BYTEARRAY_TYPECODE:
case 'B':
- case 'x': // value will be discarded
val = ((unsigned char*)p)[index];
break;
case 'h':
@@ -330,7 +329,11 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **
}
}
- mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
+ if (val_type == 'x') {
+ memset(p, 0, 1);
+ } else {
+ mp_binary_set_int(MIN((size_t)size, sizeof(val)), struct_type == '>', p, val);
+ }
}
void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in) {
@@ -379,8 +382,6 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
case 'B':
((unsigned char*)p)[index] = val;
break;
- case 'x':
- ((unsigned char*)p)[index] = 0;
case 'h':
((short*)p)[index] = val;
break;