Skip to content

Commit 2fa9de8

Browse files
committedNov 4, 2016
Fixes for Cedric's static analysis notes. Issue #17.
1 parent e74c99c commit 2fa9de8

File tree

11 files changed

+63
-9
lines changed

11 files changed

+63
-9
lines changed
 

‎apps/efiboot/efiboot.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,8 @@ Return Value:
553553
if ((VariableDataSize % sizeof(UINT16)) != 0) {
554554
fprintf(stderr,
555555
"efiboot: Warning: BootOrder variable size was %d, not a "
556-
"multiple of 2!\n");
556+
"multiple of 2!\n",
557+
VariableDataSize);
557558
}
558559

559560
Count = VariableDataSize / sizeof(UINT16);

‎apps/lib/chalk/cif.c

+1
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,7 @@ Return Value:
10061006
Count += 1;
10071007
}
10081008

1009+
va_end(ArgumentList);
10091010
Status = ChalkExecuteFunction(Interpreter, Function, List, ReturnValue);
10101011

10111012
CExecuteFunctionEnd:

‎apps/setup/win32/io.c

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ Return Value:
244244

245245
PathCopy = strdup(Destination->Path);
246246
if (PathCopy == NULL) {
247+
free(IoHandle);
247248
return NULL;
248249
}
249250

‎apps/swiss/id.c

+14-2
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,13 @@ Return Value:
490490
if (((Options & ID_OPTION_EXCLUSIVE_MASK) == 0) ||
491491
((Options & ID_OPTION_PRINT_NAMES) != 0)) {
492492

493-
SwGetUserNameFromId(UserId, &UserName);
493+
if (SwGetUserNameFromId(UserId, &UserName) != 0) {
494+
495+
assert(UserName == NULL);
496+
497+
printf("%u", (unsigned int)UserId);
498+
return;
499+
}
494500
}
495501

496502
//
@@ -558,7 +564,13 @@ Return Value:
558564
if (((Options & ID_OPTION_EXCLUSIVE_MASK) == 0) ||
559565
((Options & ID_OPTION_PRINT_NAMES) != 0)) {
560566

561-
SwGetGroupNameFromId(GroupId, &GroupName);
567+
if (SwGetGroupNameFromId(GroupId, &GroupName) != 0) {
568+
569+
assert(GroupName == NULL);
570+
571+
printf("%u", (unsigned int)GroupId);
572+
return;
573+
}
562574
}
563575

564576
//

‎apps/swiss/ls/ls.c

+10-2
Original file line numberDiff line numberDiff line change
@@ -2130,8 +2130,16 @@ Return Value:
21302130
if (((Context->Flags & LS_OPTION_LONG_FORMAT) != 0) &&
21312131
((Context->Flags & LS_OPTION_PRINT_USER_GROUP_NUMBERS) == 0)) {
21322132

2133-
SwGetUserNameFromId(Stat->st_uid, &(NewFile->OwnerName));
2134-
SwGetGroupNameFromId(Stat->st_gid, &(NewFile->GroupName));
2133+
if (SwGetUserNameFromId(Stat->st_uid, &(NewFile->OwnerName)) != 0) {
2134+
2135+
assert(NewFile->OwnerName == NULL);
2136+
}
2137+
2138+
if (SwGetGroupNameFromId(Stat->st_gid, &(NewFile->GroupName)) !=
2139+
0) {
2140+
2141+
assert(NewFile->GroupName == NULL);
2142+
}
21352143
}
21362144

21372145
} else {

‎apps/swiss/ps.c

+21
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,9 @@ Return Value:
15451545
case PsDataEffectiveUserIdentifier:
15461546
Result = SwGetUserNameFromId(Information->EffectiveUserId, &StringData);
15471547
if (Result != 0) {
1548+
1549+
assert(StringData == NULL);
1550+
15481551
DataAvailable = FALSE;
15491552
break;
15501553
}
@@ -1555,6 +1558,9 @@ Return Value:
15551558
case PsDataRealUserIdentifier:
15561559
Result = SwGetUserNameFromId(Information->RealUserId, &StringData);
15571560
if (Result != 0) {
1561+
1562+
assert(StringData == NULL);
1563+
15581564
DataAvailable = FALSE;
15591565
break;
15601566
}
@@ -1565,6 +1571,9 @@ Return Value:
15651571
case PsDataRealGroupIdentifier:
15661572
Result = SwGetGroupNameFromId(Information->RealGroupId, &StringData);
15671573
if (Result != 0) {
1574+
1575+
assert(StringData == NULL);
1576+
15681577
DataAvailable = FALSE;
15691578
break;
15701579
}
@@ -1577,6 +1586,9 @@ Return Value:
15771586
&StringData);
15781587

15791588
if (Result != 0) {
1589+
1590+
assert(StringData == NULL);
1591+
15801592
DataAvailable = FALSE;
15811593
break;
15821594
}
@@ -2131,6 +2143,9 @@ Return Value:
21312143
&GroupName);
21322144

21332145
if (Result != 0) {
2146+
2147+
assert(GroupName == NULL);
2148+
21342149
continue;
21352150
}
21362151
}
@@ -2237,6 +2252,9 @@ Return Value:
22372252
&UserName);
22382253

22392254
if (Result != 0) {
2255+
2256+
assert(UserName == NULL);
2257+
22402258
continue;
22412259
}
22422260
}
@@ -2283,6 +2301,9 @@ Return Value:
22832301
&UserName);
22842302

22852303
if (Result != 0) {
2304+
2305+
assert(UserName == NULL);
2306+
22862307
continue;
22872308
}
22882309
}

‎apps/swiss/ssdaemon.c

+2
Original file line numberDiff line numberDiff line change
@@ -932,9 +932,11 @@ Return Value:
932932
}
933933

934934
if (fscanf(File, "%u", &ScannedPid) != 1) {
935+
fclose(File);
935936
return EINVAL;
936937
}
937938

939+
fclose(File);
938940
SsDaemonMatchPid(Context, ScannedPid);
939941
return 0;
940942
}

‎drivers/dma/bcm2709/dmab2709.c

-2
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,6 @@ Return Value:
13761376
PHYSICAL_ADDRESS PreviousAddress;
13771377
PDMA_BCM2709_CONTROL_BLOCK PreviousControlBlock;
13781378
UINTN Remaining;
1379-
UINTN Size;
13801379
KSTATUS Status;
13811380
UINTN TransferSize;
13821381

@@ -1508,7 +1507,6 @@ Return Value:
15081507
FragmentOffset = 0;
15091508
}
15101509

1511-
Size += BytesThisRound;
15121510
TransferSize += BytesThisRound;
15131511
Remaining -= BytesThisRound;
15141512
PreviousAddress += BytesThisRound;

‎kernel/armv7/prochw.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ Return Value:
128128
}
129129

130130
ExceptionStacks = ArP0ExceptionStacks;
131+
InterruptTable = ArP0InterruptTable;
131132
if (PhysicalMode == FALSE) {
132133

133134
//
134135
// Use the globals if this is the boot processor because the memory
135136
// subsystem is not yet online.
136137
//
137138

138-
InterruptTable = ArP0InterruptTable;
139139
if (ProcessorStructures == NULL) {
140140
ProcessorBlock = &ArP0ProcessorBlock;
141141

‎uefi/plat/panda/init/clock.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,13 @@ Return Value:
632632
UINT32 Mask;
633633
UINT32 Register;
634634

635-
Mask = 1 << BitCount;
635+
if (BitCount == 32) {
636+
Mask = 0;
637+
638+
} else {
639+
Mask = 1 << BitCount;
640+
}
641+
636642
Mask -= 1;
637643
Register = OMAP4_READ32(Address) & ~(Mask << StartBit);
638644
Register |= Value << StartBit;

‎uefi/plat/veyron/fwbuild/fwbuild.c

+4
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,10 @@ Return Value:
456456
fclose(FirmwareImage);
457457
}
458458

459+
if (KeyBlockFile != NULL) {
460+
fclose(KeyBlockFile);
461+
}
462+
459463
if (FirmwareImageBuffer != NULL) {
460464
free(FirmwareImageBuffer);
461465
}

0 commit comments

Comments
 (0)
Please sign in to comment.