diff --git a/docs/misra/safe.json b/docs/misra/safe.json index e3489dba8e..3584cb90c6 100644 --- a/docs/misra/safe.json +++ b/docs/misra/safe.json @@ -116,6 +116,14 @@ }, { "id": "SAF-14-safe", + "analyser": { + "eclair": "MC3A2.R10.1" + }, + "name": "Rule 10.1: use boolean as an array index", + "text": "Using a boolean type as an array index is safe." + }, + { + "id": "SAF-15-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used" diff --git a/xen/common/time.c b/xen/common/time.c index 92f7b72464..c873b5731b 100644 --- a/xen/common/time.c +++ b/xen/common/time.c @@ -84,7 +84,8 @@ struct tm gmtime(unsigned long t) } tbuf.tm_year = y - 1900; tbuf.tm_yday = days; - ip = (const unsigned short int *)__mon_lengths[__isleap(y)]; + /* SAF-14-safe use boolean as an array index */ + ip = __mon_lengths[__isleap(y)]; for ( y = 0; days >= ip[y]; ++y ) days -= ip[y]; tbuf.tm_mon = y; diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c index 9478fcd11c..58f3331520 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -315,7 +315,7 @@ static int queue_poll_cons(struct arm_smmu_queue *q, bool sync, bool wfe) while (queue_sync_cons_in(q), (sync ? !queue_empty(&q->llq) : queue_full(&q->llq))) { - if ((NOW() > timeout) > 0) + if (NOW() > timeout) return -ETIMEDOUT; if (wfe) {