Skip to content

Commit 18e91d9

Browse files
authored
Merge pull request #2205 from jepler/scan-build-fixes
Fix several trivial problems found by clang 7's scan-build
2 parents cc3e0a0 + cd0ed65 commit 18e91d9

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

py/binary.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, con
184184
val = -1;
185185
}
186186
for (uint i = 0; i < size; i++) {
187-
val <<= 8;
187+
val *= 256;
188188
val |= *src;
189189
src += delta;
190190
}

py/gc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ void *gc_alloc(size_t n_bytes, bool has_finaliser, bool long_lived) {
509509
gc_collect();
510510
collected = 1;
511511
GC_ENTER();
512-
collected = true;
513512
}
514513
#endif
515514

py/objtype.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,10 @@ mp_obj_t mp_obj_instance_make_new(const mp_obj_type_t *self, size_t n_args, cons
336336
mp_obj_t *args2 = m_new(mp_obj_t, 1 + n_args + 2 * n_kw);
337337
args2[0] = MP_OBJ_FROM_PTR(self);
338338
memcpy(args2 + 1, args, n_args * sizeof(mp_obj_t));
339-
// copy in kwargs
340-
memcpy(args2 + 1 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
339+
if (kw_args) {
340+
// copy in kwargs
341+
memcpy(args2 + 1 + n_args, kw_args->table, 2 * n_kw * sizeof(mp_obj_t));
342+
}
341343
new_ret = mp_call_function_n_kw(init_fn[0], n_args + 1, n_kw, args2);
342344
m_del(mp_obj_t, args2, 1 + n_args + 2 * n_kw);
343345
}

py/showbc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const byte *mp_bytecode_print_str(const byte *ip) {
185185
num--;
186186
}
187187
do {
188-
num = (num << 7) | (*ip & 0x7f);
188+
num = (num * 128) | (*ip & 0x7f);
189189
} while ((*ip++ & 0x80) != 0);
190190
printf("LOAD_CONST_SMALL_INT " INT_FMT, num);
191191
break;

0 commit comments

Comments
 (0)