Chameleon

Chameleon Commit Details

Date:2011-12-23 19:13:51 (12 years 4 months ago)
Author:JrCs
Commit:1742
Parents: 1741
Message:Fix C errors reports by Clang static analyzer
Changes:
M/trunk/i386/libsaio/smbios.h
M/trunk/i386/libsaio/acpi_patcher.c
M/trunk/i386/libsaio/gma.c
M/trunk/i386/libsaio/fake_efi.c
M/trunk/i386/libsaio/usb.c
M/trunk/i386/libsaio/disk.c
M/trunk/i386/libsaio/nvidia.c
M/trunk/i386/boot2/options.c
M/trunk/i386/libsa/string.c
M/trunk/i386/libsa/prf.c
M/trunk/i386/libsa/strtol.c
M/trunk/i386/libsaio/smbios_decode.c
M/trunk/i386/libsaio/convert.c
M/trunk/i386/libsaio/pci.h

File differences

trunk/i386/libsaio/acpi_patcher.c
819819
820820
821821
822
822
823823
824824
825825
sprintf(filename, i>0?"SSDT-%d.aml":"SSDT.aml", i);
if(new_ssdt[ssdt_count] = loadACPITable(filename))
if ( (new_ssdt[ssdt_count] = loadACPITable(filename)) )
{
ssdt_count++;
}
trunk/i386/libsaio/gma.c
115115
116116
117117
118
119
118
119
120120
121121
122122
123123
124124
125
126
125
126
127127
128128
129129
130130
131131
132
132
133133
134134
135135
devprop_add_value(device, "model", (uint8_t*)model, (strlen(model) + 1));
devprop_add_value(device, "device_type", (uint8_t*)"display", 8);
if ((model == (char *)"Mobile GMA950")
|| (model == (char *)"Mobile GMA3150"))
if ((strcmp("Mobile GMA950", model) == 0) ||
(strcmp("Mobile GMA3150",model) == 0))
{
devprop_add_value(device, "AAPL,HasPanel", reg_TRUE, 4);
devprop_add_value(device, "built-in", &BuiltIn, 1);
devprop_add_value(device, "class-code", ClassFix, 4);
}
else if ((model == (char *)"Desktop GMA950")
|| (model == (char *)"Desktop GMA3150"))
else if ((strcmp("Desktop GMA950", model) == 0) ||
(strcmp("Desktop GMA3150",model) == 0))
{
BuiltIn = 0x01;
devprop_add_value(device, "built-in", &BuiltIn, 1);
devprop_add_value(device, "class-code", ClassFix, 4);
}
else if (model == (char *)"GMAX3100")
else if (strcmp("GMAX3100",model) == 0)
{
devprop_add_value(device, "AAPL,HasPanel",GMAX3100_vals[0], 4);
devprop_add_value(device, "AAPL,SelfRefreshSupported",GMAX3100_vals[1], 4);
trunk/i386/libsaio/usb.c
244244
245245
246246
247
247
248248
249249
250250
//We try soft reset first - some systems hang on reboot with hard reset
// Definitely needed during reboot on 10.4.6
isOwnershipConflict = ((legacy[3] & 1 != 0) && (legacy[2] & 1 != 0));
isOwnershipConflict = (((legacy[3] & 1) != 0) && ((legacy[2] & 1) != 0));
if (!alwaysHardBIOSReset && isOwnershipConflict) {
DBG("EHCI - Ownership conflict - attempting soft reset ...\n");
DBG("EHCI - toggle OS Ownership to 0\n");
trunk/i386/libsaio/nvidia.c
10041004
10051005
10061006
1007
1007
10081008
10091009
10101010
......
10231023
10241024
10251025
1026
1026
10271027
10281028
10291029
channel1 |= ( 0x1 << entries[i].index);
entries[i].type = TYPE_GROUPED;
if ((entries[i-1].type == 0x0))
if ( entries[i-1].type == 0x0 )
{
channel1 |= ( 0x1 << entries[i-1].index);
entries[i-1].type = TYPE_GROUPED;
channel2 |= ( 0x1 << entries[i].index);
entries[i].type = TYPE_GROUPED;
if ((entries[i - 1].type == 0x0))
if ( entries[i - 1].type == 0x0 )
{
channel2 |= ( 0x1 << entries[i-1].index);
entries[i-1].type = TYPE_GROUPED;
trunk/i386/libsaio/disk.c
11441144
11451145
11461146
1147
1147
11481148
11491149
11501150
......
11851185
11861186
11871187
1188
1188
11891189
11901190
11911191
result = FDISK_NTFS;
else if (BeFSProbe(probeBuffer))
result = FDISK_BEFS;
else if (fatbits=MSDOSProbe(probeBuffer))
else if ( (fatbits = MSDOSProbe(probeBuffer)) )
{
switch (fatbits)
{
struct DiskBVMap * map = NULL;
void *buffer = malloc(BPS);
int error;
if ( error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer ) != 0) {
if ( (error = readBytes( biosdev, /*secno*/0, 0, BPS, buffer )) != 0) {
verbose("Failed to read boot sector from BIOS device %02xh. Error=%d\n", biosdev, error);
goto scanErr;
}
trunk/i386/libsaio/smbios_decode.c
2323
2424
2525
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
2660
2761
2862
extern char *getSMBStringForField(SMBStructHeader *structHeader, uint8_t field);
static const char *
SMBMemoryDeviceTypes[] =
{
"RAM", /* 00h Undefined */
"RAM", /* 01h Other */
"RAM", /* 02h Unknown */
"DRAM", /* 03h DRAM */
"EDRAM", /* 04h EDRAM */
"VRAM", /* 05h VRAM */
"SRAM", /* 06h SRAM */
"RAM", /* 07h RAM */
"ROM", /* 08h ROM */
"FLASH", /* 09h FLASH */
"EEPROM", /* 0Ah EEPROM */
"FEPROM", /* 0Bh FEPROM */
"EPROM", /* 0Ch EPROM */
"CDRAM", /* 0Dh CDRAM */
"3DRAM", /* 0Eh 3DRAM */
"SDRAM", /* 0Fh SDRAM */
"SGRAM", /* 10h SGRAM */
"RDRAM", /* 11h RDRAM */
"DDR SDRAM", /* 12h DDR */
"DDR2 SDRAM", /* 13h DDR2 */
"DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */
"RAM",/* 15h unused */
"RAM",/* 16h unused */
"RAM",/* 17h unused */
"DDR3",/* 18h DDR3, chosen in [5776134] */
};
static const int
kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /
sizeof(SMBMemoryDeviceTypes[0]);
//-------------------------------------------------------------------------------------------------------------------------
// BIOSInformation
//-------------------------------------------------------------------------------------------------------------------------
trunk/i386/libsaio/smbios.h
386386
387387
388388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423389
424390
425391
SMBWord Data[];
} __attribute__((packed)) SMBMemorySPD;
static const char *
SMBMemoryDeviceTypes[] =
{
"RAM", /* 00h Undefined */
"RAM", /* 01h Other */
"RAM", /* 02h Unknown */
"DRAM", /* 03h DRAM */
"EDRAM", /* 04h EDRAM */
"VRAM", /* 05h VRAM */
"SRAM", /* 06h SRAM */
"RAM", /* 07h RAM */
"ROM", /* 08h ROM */
"FLASH", /* 09h FLASH */
"EEPROM", /* 0Ah EEPROM */
"FEPROM", /* 0Bh FEPROM */
"EPROM", /* 0Ch EPROM */
"CDRAM", /* 0Dh CDRAM */
"3DRAM", /* 0Eh 3DRAM */
"SDRAM", /* 0Fh SDRAM */
"SGRAM", /* 10h SGRAM */
"RDRAM", /* 11h RDRAM */
"DDR SDRAM", /* 12h DDR */
"DDR2 SDRAM", /* 13h DDR2 */
"DDR2 FB-DIMM", /* 14h DDR2 FB-DIMM */
"RAM",/* 15h unused */
"RAM",/* 16h unused */
"RAM",/* 17h unused */
"DDR3",/* 18h DDR3, chosen in [5776134] */
};
static const int
kSMBMemoryDeviceTypeCount = sizeof(SMBMemoryDeviceTypes) /
sizeof(SMBMemoryDeviceTypes[0]);
//
// OEM Processor Type (Apple Specific - Type 131)
//
trunk/i386/libsaio/convert.c
9494
9595
9696
97
98
99
97
98
99
100100
101101
102102
hexNibble = hexStr[hexStrIdx];
// ignore all chars except valid hex numbers
if (hexNibble >= '0' && hexNibble <= '9'
|| hexNibble >= 'A' && hexNibble <= 'F'
|| hexNibble >= 'a' && hexNibble <= 'f')
if ( (hexNibble >= '0' && hexNibble <= '9') ||
(hexNibble >= 'A' && hexNibble <= 'F') ||
(hexNibble >= 'a' && hexNibble <= 'f') )
{
hexByte[hexNibbleIdx++] = hexNibble;
trunk/i386/libsaio/pci.h
4343
4444
4545
46
46
4747
4848
4949
struct pci_dt_t*next;
} pci_dt_t;
#define PCIADDR(bus, dev, func) (1 << 31) | (bus << 16) | (dev << 11) | (func << 8)
#define PCIADDR(bus, dev, func) ((1 << 31) | (bus << 16) | (dev << 11) | (func << 8))
#define PCI_ADDR_REG0xcf8
#define PCI_DATA_REG0xcfc
trunk/i386/libsaio/fake_efi.c
655655
656656
657657
658
658
659659
660660
661661
{
// Check selected volume's Extra.
sprintf(dirSpecSMBIOS, "/Extra/%s", filename);
if (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig))
if ( (err = loadConfigFile(dirSpecSMBIOS, &bootInfo->smbiosConfig)) )
{
// Check booter volume/rdbt Extra.
sprintf(dirSpecSMBIOS, "bt(0,0)/Extra/%s", filename);
trunk/i386/boot2/options.c
135135
136136
137137
138
138
139139
140140
141141
lasttime=time18();
}
if (ch = readKeyboardStatus())
if ( (ch = readKeyboardStatus()) )
break;
// Count can be interrupted by holding down shift,
trunk/i386/libsa/string.c
151151
152152
153153
154
154
155155
156156
157157
strcpy(char * s1, const char * s2)
{
register char *ret = s1;
while (*s1++ = *s2++)
while ((*s1++ = *s2++))
continue;
return ret;
}
trunk/i386/libsa/prf.c
151151
152152
153153
154
154
155155
156156
157157
break;
case 's':
s = (char *)*adx;
while (c = *s++) {
while ((c = *s++)) {
(*putfn_p)(c, putfn_arg);
width++;
}
trunk/i386/libsa/strtol.c
148148
149149
150150
151
151
152152
153153
154154
......
220220
221221
222222
223
223
224224
225225
226226
......
291291
292292
293293
294
294
295295
296296
297297
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else {
any = 1;

Archive Download the corresponding diff file

Revision: 1742