Skip to content

Commit 96fdbca

Browse files
DeHesshenrikbrixandersen
authored andcommitted
coding guidelines: comply with MISRA Rule 15.2
- moved switch clause to avoid backward jump Signed-off-by: Hess Nathan <[email protected]>
1 parent ebacd80 commit 96fdbca

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

lib/os/cbprintf_complete.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,6 +1601,26 @@ int z_cbvprintf_impl(cbprintf_cb out, void *ctx, const char *fp,
16011601

16021602
break;
16031603
}
1604+
case 'p':
1605+
/* Implementation-defined: null is "(nil)", non-null
1606+
* has 0x prefix followed by significant address hex
1607+
* digits, no leading zeros.
1608+
*/
1609+
if (value->ptr != NULL) {
1610+
bps = encode_uint((uintptr_t)value->ptr, conv,
1611+
buf, bpe);
1612+
1613+
/* Use 0x prefix */
1614+
conv->altform_0c = true;
1615+
conv->specifier = 'x';
1616+
1617+
goto prec_int_pad0;
1618+
}
1619+
1620+
bps = "(nil)";
1621+
bpe = bps + 5;
1622+
1623+
break;
16041624
case 'c':
16051625
bps = buf;
16061626
buf[0] = CHAR_IS_SIGNED ? value->sint : value->uint;
@@ -1653,26 +1673,6 @@ int z_cbvprintf_impl(cbprintf_cb out, void *ctx, const char *fp,
16531673
}
16541674
}
16551675

1656-
break;
1657-
case 'p':
1658-
/* Implementation-defined: null is "(nil)", non-null
1659-
* has 0x prefix followed by significant address hex
1660-
* digits, no leading zeros.
1661-
*/
1662-
if (value->ptr != NULL) {
1663-
bps = encode_uint((uintptr_t)value->ptr, conv,
1664-
buf, bpe);
1665-
1666-
/* Use 0x prefix */
1667-
conv->altform_0c = true;
1668-
conv->specifier = 'x';
1669-
1670-
goto prec_int_pad0;
1671-
}
1672-
1673-
bps = "(nil)";
1674-
bpe = bps + 5;
1675-
16761676
break;
16771677
case 'n':
16781678
if (IS_ENABLED(CONFIG_CBPRINTF_N_SPECIFIER)) {

0 commit comments

Comments
 (0)