target/arc: fix clang static analyzer warnings
Fixes: * Removed typo in *bitfields initializations. * Removed potentional memory leak allocating reg_data_type_struct_field/reg_data_type_flags_field objects. * Initialize buffers with "0" before usage in buf_set_u32(). * Removed memory leak in jim_arc_add_reg(). Change-Id: Iefde57cd4a48c4f3350c376475df8642607f52ff Signed-off-by: Evgeniy Didin <didin@synopsys.com> Reviewed-on: http://openocd.zylin.com/5480 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
This commit is contained in:
committed by
Oleksij Rempel
parent
9ee9bdd2f9
commit
39d54ee969
@@ -163,7 +163,8 @@ static int jim_arc_add_reg_type_flags(Jim_Interp *interp, int argc,
|
||||
struct arc_reg_data_type *type = calloc(1, sizeof(*type));
|
||||
struct reg_data_type_flags *flags = &type->data_type_flags;
|
||||
struct reg_data_type_flags_field *fields = calloc(fields_sz, sizeof(*fields));
|
||||
struct arc_reg_bitfield *bitfields = calloc(fields_sz, sizeof(*type));
|
||||
type->reg_type_flags_field = fields;
|
||||
struct arc_reg_bitfield *bitfields = calloc(fields_sz, sizeof(*bitfields));
|
||||
if (!(type && fields && bitfields)) {
|
||||
Jim_SetResultFormatted(goi.interp, "Failed to allocate memory.");
|
||||
goto fail;
|
||||
@@ -528,7 +529,8 @@ static int jim_arc_add_reg_type_struct(Jim_Interp *interp, int argc,
|
||||
struct arc_reg_data_type *type = calloc(1, sizeof(*type));
|
||||
struct reg_data_type_struct *struct_type = &type->data_type_struct;
|
||||
struct reg_data_type_struct_field *fields = calloc(fields_sz, sizeof(*fields));
|
||||
struct arc_reg_bitfield *bitfields = calloc(fields_sz, sizeof(*type));
|
||||
type->reg_type_struct_field = fields;
|
||||
struct arc_reg_bitfield *bitfields = calloc(fields_sz, sizeof(*bitfields));
|
||||
if (!(type && fields && bitfields)) {
|
||||
Jim_SetResultFormatted(goi.interp, "Failed to allocate memory.");
|
||||
goto fail;
|
||||
@@ -789,6 +791,7 @@ static int jim_arc_add_reg(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
|
||||
target = get_current_target(ctx);
|
||||
if (!target) {
|
||||
Jim_SetResultFormatted(goi.interp, "No current target");
|
||||
free_reg_desc(reg);
|
||||
return JIM_ERR;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user