Fixed some pedantic stuff for compiling with g++

This commit is contained in:
planetbeing 2008-04-22 00:24:32 -04:00
Родитель 068833912e
Коммит aa5add7cfc
7 изменённых файлов: 32 добавлений и 29 удалений

Просмотреть файл

@ -137,7 +137,7 @@ int buildDmg(const char* source, const char* dest) {
printf("Inserting nsiz data\n"); fflush(stdout);
myNSiz = malloc(sizeof(NSizResource));
myNSiz = (NSizResource*) malloc(sizeof(NSizResource));
memset(myNSiz, 0, sizeof(NSizResource));
myNSiz->isVolume = TRUE;
myNSiz->blockChecksum2 = uncompressedToken.block;

Просмотреть файл

@ -316,7 +316,7 @@ ResourceKey* makePlst();
ResourceKey* makeSize(HFSPlusVolumeHeader* volumeHeader);
void readDriverDescriptorMap(FILE* file, ResourceKey* resources);
DriverDescriptorRecord* createDriverDescriptorMap();
DriverDescriptorRecord* createDriverDescriptorMap(uint32_t numSectors);
void writeDriverDescriptorMap(FILE* file, DriverDescriptorRecord* DDM, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources);
void readApplePartitionMap(FILE* file, ResourceKey* resources);
Partition* createApplePartitionMap(uint32_t numSectors, const char* volumeType);

Просмотреть файл

@ -431,7 +431,7 @@ void readDriverDescriptorMap(FILE* file, ResourceKey* resources) {
blkx = (BLKXTable*) (getDataByID(getResourceByKey(resources, "blkx"), -1)->data);
info.offset = 0;
info.bufferSize = 512;
info.buffer = malloc(info.bufferSize);
info.buffer = (unsigned char*) malloc(info.bufferSize);
extractBLKX(file, (void*)(&info), blkx, &memWrite, &memSeek, &memTell);
record = (DriverDescriptorRecord*)info.buffer;
flipDriverDescriptorRecord(record, FALSE);
@ -458,7 +458,7 @@ void readDriverDescriptorMap(FILE* file, ResourceKey* resources) {
DriverDescriptorRecord* createDriverDescriptorMap(uint32_t numSectors) {
DriverDescriptorRecord* toReturn;
toReturn = malloc(SECTOR_SIZE);
toReturn = (DriverDescriptorRecord*) malloc(SECTOR_SIZE);
memset(toReturn, 0, SECTOR_SIZE);
toReturn->sbSig = DRIVER_DESCRIPTOR_SIGNATURE;
@ -481,7 +481,7 @@ void writeDriverDescriptorMap(FILE* file, DriverDescriptorRecord* DDM, ChecksumF
ChecksumToken uncompressedToken;
DriverDescriptorRecord* buffer;
buffer = malloc(DDM_SIZE * SECTOR_SIZE);
buffer = (DriverDescriptorRecord*) malloc(DDM_SIZE * SECTOR_SIZE);
memcpy(buffer, DDM, DDM_SIZE * SECTOR_SIZE);
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
@ -510,7 +510,7 @@ void writeApplePartitionMap(FILE* file, Partition* partitions, ChecksumFunc data
NSizResource* nsiz;
CSumResource csum;
buffer = malloc(PARTITION_SIZE * SECTOR_SIZE);
buffer = (Partition*) malloc(PARTITION_SIZE * SECTOR_SIZE);
memcpy(buffer, partitions, PARTITION_SIZE * SECTOR_SIZE);
memset(&uncompressedToken, 0, sizeof(uncompressedToken));
@ -532,7 +532,7 @@ void writeApplePartitionMap(FILE* file, Partition* partitions, ChecksumFunc data
*resources = insertData(*resources, "blkx", 0, "Apple (Apple_partition_map : 1)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
*resources = insertData(*resources, "cSum", 0, "", (const char*) (&csum), sizeof(csum), 0);
nsiz = malloc(sizeof(NSizResource));
nsiz = (NSizResource*) malloc(sizeof(NSizResource));
memset(nsiz, 0, sizeof(NSizResource));
nsiz->isVolume = FALSE;
nsiz->blockChecksum2 = uncompressedToken.block;
@ -576,7 +576,7 @@ void writeATAPI(FILE* file, ChecksumFunc dataForkChecksum, void* dataForkToken,
*resources = insertData(*resources, "blkx", 1, "Macintosh (Apple_Driver_ATAPI : 2)", (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);
*resources = insertData(*resources, "cSum", 1, "", (const char*) (&csum), sizeof(csum), 0);
nsiz = malloc(sizeof(NSizResource));
nsiz = (NSizResource*) malloc(sizeof(NSizResource));
memset(nsiz, 0, sizeof(NSizResource));
nsiz->isVolume = FALSE;
nsiz->blockChecksum2 = uncompressedToken.block;
@ -604,7 +604,7 @@ void readApplePartitionMap(FILE* file, ResourceKey* resources) {
blkx = (BLKXTable*) (getDataByID(getResourceByKey(resources, "blkx"), 0)->data);
info.offset = 0;
info.bufferSize = 512;
info.buffer = malloc(info.bufferSize);
info.buffer = (unsigned char*) malloc(info.bufferSize);
extractBLKX(file, (void*)(&info), blkx, &memWrite, &memSeek, &memTell);
partition = (Partition*)info.buffer;
flipPartition(partition, FALSE);
@ -685,7 +685,7 @@ HFSPlusVolumeHeader* readVolumeHeader(FILE* file) {
Partition* createApplePartitionMap(uint32_t numSectors, const char* volumeType) {
Partition* partition;
partition = malloc(SECTOR_SIZE * PARTITION_SIZE);
partition = (Partition*) malloc(SECTOR_SIZE * PARTITION_SIZE);
memset(partition, 0, SECTOR_SIZE * PARTITION_SIZE);
partition[0].pmSig = APPLE_PARTITION_MAP_SIGNATURE;

Просмотреть файл

@ -475,8 +475,8 @@ ResourceKey* writeNSiz(NSizResource* nSiz) {
curNSiz = nSiz;
key = malloc(sizeof(ResourceKey));
key->key = malloc(sizeof("nsiz") + 1);
key = (ResourceKey*) malloc(sizeof(ResourceKey));
key->key = (unsigned char*) malloc(sizeof("nsiz") + 1);
strcpy((char*) key->key, "nsiz");
key->next = NULL;
key->flipData = NULL;
@ -485,16 +485,16 @@ ResourceKey* writeNSiz(NSizResource* nSiz) {
while(curNSiz != NULL) {
writeNSizResource(curNSiz, buffer);
if(key->data == NULL) {
key->data = malloc(sizeof(ResourceData));
key->data = (ResourceData*) malloc(sizeof(ResourceData));
curData = key->data;
} else {
curData->next = malloc(sizeof(ResourceData));
curData->next = (ResourceData*) malloc(sizeof(ResourceData));
curData = curData->next;
}
curData->attributes = 0;
curData->id = curNSiz->partitionNumber;
curData->name = malloc(sizeof(char));
curData->name = (unsigned char*) malloc(sizeof(char));
curData->name[0] = '\0';
curData->next = NULL;
curData->dataLength = sizeof(char) * strlen(buffer);
@ -767,7 +767,7 @@ ResourceKey* insertData(ResourceKey* resources, const char* key, int id, const c
curResource = lastResource->next;
}
curResource->key = malloc(strlen(key) + 1);
curResource->key = (unsigned char*) malloc(strlen(key) + 1);
strcpy((char*) curResource->key, key);
curResource->next = NULL;
@ -786,7 +786,7 @@ ResourceKey* insertData(ResourceKey* resources, const char* key, int id, const c
}
if(curResource->data == NULL) {
curData = malloc(sizeof(ResourceData));
curData = (ResourceData*) malloc(sizeof(ResourceData));
curResource->data = curData;
curData->next = NULL;
} else {
@ -799,7 +799,7 @@ ResourceKey* insertData(ResourceKey* resources, const char* key, int id, const c
}
if(curData->id != id) {
curData->next = malloc(sizeof(ResourceData));
curData->next = (ResourceData*) malloc(sizeof(ResourceData));
curData = curData->next;
curData->next = NULL;
} else {
@ -811,9 +811,9 @@ ResourceKey* insertData(ResourceKey* resources, const char* key, int id, const c
curData->attributes = attributes;
curData->dataLength = dataLength;
curData->id = id;
curData->name = malloc(strlen(name) + 1);
curData->name = (unsigned char*) malloc(strlen(name) + 1);
strcpy((char*) curData->name, name);
curData->data = malloc(dataLength);
curData->data = (unsigned char*) malloc(dataLength);
memcpy(curData->data, data, dataLength);
int i = 0;

Просмотреть файл

@ -3,7 +3,7 @@
static int flatFileRead(io_func* io, off_t location, size_t size, void *buffer) {
FILE* file;
file = io->data;
file = (FILE*) io->data;
if(size == 0) {
return TRUE;
@ -41,7 +41,7 @@ static int flatFileWrite(io_func* io, off_t location, size_t size, void *buffer)
return TRUE;
}
file = io->data;
file = (FILE*) io->data;
if(fseeko(file, location, SEEK_SET) != 0) {
perror("fseek");
@ -59,7 +59,9 @@ static int flatFileWrite(io_func* io, off_t location, size_t size, void *buffer)
}
static void closeFlatFile(io_func* io) {
FILE* file = io->data;
FILE* file;
file = (FILE*) io->data;
fclose(file);
free(io);

Просмотреть файл

@ -466,6 +466,7 @@ int move(const char* source, const char* dest, Volume* volume);
int removeFile(const char* fileName, Volume* volume);
HFSCatalogNodeID newFolder(const char* pathName, Volume* volume);
HFSCatalogNodeID newFile(const char* pathName, Volume* volume);
int chmodFile(const char* pathName, int mode, Volume* volume);
HFSPlusCatalogRecord* getRecordByCNID(HFSCatalogNodeID CNID, Volume* volume);
CatalogRecordList* getFolderContents(HFSCatalogNodeID CNID, Volume* volume);

Просмотреть файл

@ -60,7 +60,7 @@ int allocate(RawFile* rawFile, off_t size) {
}
if(lastExtent == NULL) {
rawFile->extents = malloc(sizeof(Extent));
rawFile->extents = (Extent*) malloc(sizeof(Extent));
lastExtent = rawFile->extents;
lastExtent->blockCount = 0;
lastExtent->next = NULL;
@ -72,7 +72,7 @@ int allocate(RawFile* rawFile, off_t size) {
while(blocksToAllocate > 0) {
if(isBlockUsed(volume, curBlock)) {
if(lastExtent->blockCount > 0) {
lastExtent->next = malloc(sizeof(Extent));
lastExtent->next = (Extent*) malloc(sizeof(Extent));
lastExtent = lastExtent->next;
lastExtent->blockCount = 0;
lastExtent->next = NULL;
@ -188,7 +188,7 @@ static int rawFileRead(io_func* io,off_t location, size_t size, void *buffer) {
if(size > possible) {
ASSERT(READ(volume->image, extent->startBlock * blockSize + location, possible, buffer), "READ");
size -= possible;
buffer += possible;
buffer = (void*)(((size_t)buffer) + possible);
extent = extent->next;
} else {
ASSERT(READ(volume->image, extent->startBlock * blockSize + location, size, buffer), "READ");
@ -241,7 +241,7 @@ static int rawFileWrite(io_func* io,off_t location, size_t size, void *buffer) {
if(size > possible) {
ASSERT(WRITE(volume->image, extent->startBlock * blockSize + location, possible, buffer), "WRITE");
size -= possible;
buffer += possible;
buffer = (void*)(((size_t)buffer) + possible);
extent = extent->next;
} else {
ASSERT(WRITE(volume->image, extent->startBlock * blockSize + location, size, buffer), "WRITE");
@ -307,7 +307,7 @@ int removeExtents(RawFile* rawFile) {
}
extentKey.startBlock = currentBlock;
descriptor = search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
if(descriptor == NULL || exact == FALSE) {
panic("inconsistent extents information!");
return FALSE;
@ -425,7 +425,7 @@ int readExtents(RawFile* rawFile) {
}
extentKey.startBlock = currentBlock;
descriptor = search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
descriptor = (HFSPlusExtentDescriptor*) search(rawFile->volume->extentsTree, (BTKey*)(&extentKey), &exact, NULL, NULL);
if(descriptor == NULL || exact == FALSE) {
panic("inconsistent extents information!");
return FALSE;