Skip to content

Commit 0619a01

Browse files
Updated C6308
Changed example to initialize and declare variable sin the same line
1 parent 03bb912 commit 0619a01

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

docs/code-quality/c6308.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ The following sample code generates this warning. This issue stems from the assi
2727

2828
void f( )
2929
{
30-
char *x;
31-
x = (char *) malloc(10);
30+
char *x = (char *) malloc(10);
3231
if (x != NULL)
3332
{
3433
x = (char *) realloc(x, 512);
@@ -46,11 +45,10 @@ To resolve the issue, you can create a temporary variable to store the return st
4645
4746
void f()
4847
{
49-
char *x, *tmp;
50-
x = (char *) malloc(10);
48+
char *x = (char *) malloc(10);
5149
if (x != NULL)
5250
{
53-
tmp = (char *) realloc(x,512);
51+
char *tmp = (char *) realloc(x,512);
5452
if (tmp != NULL)
5553
{
5654
x = tmp;

0 commit comments

Comments
 (0)