Skip to content

Commit

Permalink
Merge changes from topic "jc/coverity-fixes" into integration
Browse files Browse the repository at this point in the history
* changes:
  Fix Coverity #261967, Infinite loop
  Fix Coverity #343017, Missing unlock
  Fix Coverity #343008, Side affect in assertion
  Fix Coverity #342970, Uninitialized scalar variable
  • Loading branch information
pbeesley-arm authored and TrustedFirmware Code Review committed Aug 13, 2019
2 parents 3e516be + 9624c0a commit a8ab58e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 51 deletions.
47 changes: 0 additions & 47 deletions lib/aarch32/arm32_aeabi_divmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ static void uint_div_qr(unsigned int numerator, unsigned int denominator,
unsigned int __aeabi_uidivmod(unsigned int numerator, unsigned int denominator);

unsigned int __aeabi_uidiv(unsigned int numerator, unsigned int denominator);
unsigned int __aeabi_uimod(unsigned int numerator, unsigned int denominator);

/* returns in R0 and R1 by tail calling an asm function */
signed int __aeabi_idivmod(signed int numerator, signed int denominator);

signed int __aeabi_idiv(signed int numerator, signed int denominator);
signed int __aeabi_imod(signed int numerator, signed int denominator);

/*
* __ste_idivmod_ret_t __aeabi_idivmod(signed numerator, signed denominator)
Expand Down Expand Up @@ -106,15 +104,6 @@ unsigned int __aeabi_uidiv(unsigned int numerator, unsigned int denominator)
return qr.q;
}

unsigned int __aeabi_uimod(unsigned int numerator, unsigned int denominator)
{
struct qr qr = { .q_n = 0, .r_n = 0 };

uint_div_qr(numerator, denominator, &qr);

return qr.r;
}

unsigned int __aeabi_uidivmod(unsigned int numerator, unsigned int denominator)
{
struct qr qr = { .q_n = 0, .r_n = 0 };
Expand Down Expand Up @@ -145,42 +134,6 @@ signed int __aeabi_idiv(signed int numerator, signed int denominator)
return qr.q;
}

signed int __aeabi_imod(signed int numerator, signed int denominator)
{
signed int s;
signed int i;
signed int j;
signed int h;
struct qr qr = { .q_n = 0, .r_n = 0 };

/* in case modulo of a power of 2 */
for (i = 0, j = 0, h = 0, s = denominator; (s != 0) || (h > 1); i++) {
if (s & 1) {
j = i;
h++;
}
s = s >> 1;
}
if (h == 1)
return numerator >> j;

if (((numerator < 0) && (denominator > 0)) ||
((numerator > 0) && (denominator < 0)))
qr.q_n = 1; /* quotient shall be negate */

if (numerator < 0) {
numerator = -numerator;
qr.r_n = 1; /* remainder shall be negate */
}

if (denominator < 0)
denominator = -denominator;

uint_div_qr(numerator, denominator, &qr);

return qr.r;
}

signed int __aeabi_idivmod(signed int numerator, signed int denominator)
{
struct qr qr = { .q_n = 0, .r_n = 0 };
Expand Down
5 changes: 3 additions & 2 deletions lib/extensions/ras/ras_common.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
Expand Down Expand Up @@ -83,7 +83,8 @@ static int ras_interrupt_handler(uint32_t intr_raw, uint32_t flags,
{
struct ras_interrupt *ras_inrs = ras_interrupt_mappings.intrs;
struct ras_interrupt *selected = NULL;
int start, end, mid, probe_data, ret __unused;
int probe_data = 0;
int start, end, mid, ret __unused;

const struct err_handler_data err_data = {
.version = ERR_HANDLER_VERSION,
Expand Down
5 changes: 3 additions & 2 deletions lib/xlat_tables/aarch32/nonlpae_tables.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
* Copyright (c) 2014-2017, Arm Limited. All rights reserved.
* Copyright (c) 2014-2019, Arm Limited. All rights reserved.
* Copyright (c) 2014, STMicroelectronics International N.V.
* All rights reserved.
*
Expand Down Expand Up @@ -445,7 +445,8 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
} else {
xlat_table = (unsigned long)mmu_l2_base +
next_xlat * MMU32B_L2_TABLE_SIZE;
assert(++next_xlat <= MAX_XLAT_TABLES);
next_xlat++;
assert(next_xlat <= MAX_XLAT_TABLES);
memset((char *)xlat_table, 0,
MMU32B_L2_TABLE_SIZE);

Expand Down
2 changes: 2 additions & 0 deletions services/std_svc/spm/spm_buffers.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ int spm_response_add(uint16_t client_id, uint16_t handle, uint32_t token,
struct sprt_response *resp = &(responses[i]);

if ((resp->is_valid == 1) && (resp->token == token)) {
spin_unlock(&responses_lock);

return -1;
}
}
Expand Down

0 comments on commit a8ab58e

Please sign in to comment.