Chameleon

Chameleon Commit Details

Date:2014-01-07 09:21:09 (5 years 9 months ago)
Author:Chuck Fry
Commit:2299
Parents: 2298
Message:Correct cppcheck detected errors, make more robust against errors
Changes:
M/branches/chucko/i386/libsaio/device_inject.c

File differences

branches/chucko/i386/libsaio/device_inject.c
7575
7676
7777
78
79
7880
79
80
81
8281
8382
8483
......
8786
8887
8988
90
91
92
89
90
91
9392
9493
94
9595
9696
97
9897
9998
10099
101100
102101
103102
103
104
105
106
107
104108
105109
106110
......
144148
145149
146150
147
148
151
152
153
154
149155
150156
151157
......
172178
173179
174180
175
176181
177
178
179
182
183
184
185
186
180187
188
189
181190
182191
183192
......
397406
398407
399408
400
409
401410
402411
403412
404
405
413
414
406415
407
408
409
410
411
412
413
414
415
416
417
416
417
418
419
420
421
422
423
424
418425
419426
struct DevPropString *devprop_create_string(void)
{
string = (struct DevPropString*)malloc(sizeof(struct DevPropString));
if (string == NULL)
return NULL;
if(string == NULL)
return NULL;
memset(string, 0, sizeof(struct DevPropString));
string->length = 12;
string->WHAT2 = 0x01000000;
struct DevPropDevice *devprop_add_device(struct DevPropString *string, char *path)
{
struct DevPropDevice*device;
const charpciroot_string[] = "PciRoot(0x";
const charpci_device_string[] = "Pci(0x";
struct DevPropDevice*device = NULL;
static const charpciroot_string[] = "PciRoot(0x";
static const charpci_device_string[] = "Pci(0x";
if (string == NULL || path == NULL) {
printf("ERROR null device path\n");
return NULL;
}
device = malloc(sizeof(struct DevPropDevice));
if (strncmp(path, pciroot_string, strlen(pciroot_string))) {
printf("ERROR parsing device path\n");
return NULL;
}
if (!(device = malloc(sizeof(struct DevPropDevice)))) {
printf("ERROR malloc failed\n");
return NULL;
}
memset(device, 0, sizeof(struct DevPropDevice));
device->acpi_dev_path._UID = getPciRootUID();
}
}
if(!numpaths)
return NULL;
if (!numpaths) {
free(device);
return NULL;
}
device->numentries = 0x00;
device->string = string;
device->data = NULL;
string->length += device->length;
if(!string->entries)
if((string->entries = (struct DevPropDevice**)malloc(sizeof(device)*DEV_PROP_DEVICE_MAX_ENTRIES))== NULL)
return 0;
if (!string->entries)
if (!(string->entries = (struct DevPropDevice**) malloc(sizeof(device) * DEV_PROP_DEVICE_MAX_ENTRIES))) {
free(device);
return NULL;
}
/* FIXME: probably needs bounds checking, as well as error handling in event of malloc failure */
string->length += device->length;
string->entries[string->numentries++] = (struct DevPropDevice*)malloc(sizeof(device));
string->entries[string->numentries-1] = device;
void set_eth_builtin(pci_dt_t *eth_dev)
{
char *devicepath = get_pci_dev_path(eth_dev);
struct DevPropDevice *device = (struct DevPropDevice*)malloc(sizeof(struct DevPropDevice));
struct DevPropDevice *device = NULL;
verbose("LAN Controller [%04x:%04x] :: %s\n", eth_dev->vendor_id, eth_dev->device_id, devicepath);
if (!string)
string = devprop_create_string();
if(!string)
string = devprop_create_string();
device = devprop_add_device(string, devicepath);
if(device)
{
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata)
{
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
}
device = devprop_add_device(string, devicepath);
if(device) {
verbose("Setting up lan keys\n");
devprop_add_network_template(device, eth_dev->vendor_id);
stringdata = (uint8_t*)malloc(sizeof(uint8_t) * string->length);
if(stringdata) {
memcpy(stringdata, (uint8_t*)devprop_generate_string(string), string->length);
stringlength = string->length;
}
}
}

Archive Download the corresponding diff file

Revision: 2299