Skip to main content

IAR Embedded Workbench for RH850 3.20.x

MISRAC2012-Dir-4.13_a

In this section:
Synopsis

(Advisory) Functions which are designed to provide operations on a resource should be called in an approriate sequence. A mutex is locked and then never released. This might cause a deadlock.

Enabled by default

No

Severity/Certainty

High/Medium

highmedium.png
Full description

A mutex is locked, but not unlocked

Coding standards
MISRA C:2012 Dir-4.13

(Advisory) Functions which are designed to provide operations on a resource should be called in an appropriate sequence

Code examples

The following code example fails the check and will give a warning:

#include <DLib_Threads.h>

void example(void) {
  __iar_Rmtx *lock;
  __iar_system_Mtxinit(lock);

  __iar_system_Mtxlock(lock);
  /* Do something */
}

The following code example passes the check and will not give a warning about this issue:

#include <DLib_Threads.h>

void example(void) {
  __iar_Rmtx *lock;
  __iar_system_Mtxinit(lock);

  __iar_system_Mtxlock(lock);
  /* Do something */
  __iar_system_Mtxunlock(lock);
}