Fixed type sizes.

This commit is contained in:
2021-03-14 18:51:29 +00:00
parent 1fa25644d1
commit 7c5f015623
7 changed files with 46 additions and 35 deletions

View File

@@ -82,7 +82,7 @@ struct dosuname_version_t
int ndos_minor;
int windows_major;
int windows_minor;
int windows_mode;
unsigned long windows_mode;
int softice_major;
int softice_minor;
};

View File

@@ -44,11 +44,11 @@ Copyright (C) 2011-2021 Natalia Portillo
void Fragmentation(const char* path, size_t clusterSize)
{
size_t halfCluster = clusterSize / 2;
size_t quarterCluster = clusterSize / 4;
size_t twoCluster = clusterSize * 2;
size_t threeQuartersCluster = halfCluster + quarterCluster;
size_t twoAndThreeQuartCluster = threeQuartersCluster + twoCluster;
int32_t halfCluster = (int32_t)clusterSize / 2;
int32_t quarterCluster = (int32_t)clusterSize / 4;
int32_t twoCluster = (int32_t)clusterSize * 2;
int32_t threeQuartersCluster = halfCluster + quarterCluster;
int32_t twoAndThreeQuartCluster = threeQuartersCluster + twoCluster;
unsigned char* buffer;
OSErr rc, wRc, cRc;
Str255 str255;
@@ -107,7 +107,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "HALFCLST", halfCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "HALFCLST", halfCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pQUARCLST", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -127,7 +127,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pTWOCLST", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -147,7 +147,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWOCLST", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "TWOCLST", twoCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pTRQTCLST", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -167,7 +167,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n",
"TRQTCLST",
threeQuartersCluster,
rc,
@@ -192,7 +192,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n",
"TWTQCLST",
twoAndThreeQuartCluster,
rc,
@@ -217,7 +217,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO1", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "TWO1", twoCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pTWO2", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -237,7 +237,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO2", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "TWO2", twoCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pTWO3", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -260,7 +260,7 @@ void Fragmentation(const char* path, size_t clusterSize)
printf("\tDeleting \"TWO2\".\n");
rc = HDelete(refNum, dirId, "\pTWO2");
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n", "TWO3", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n", "TWO3", twoCluster, rc, wRc, cRc);
rc = HCreate(refNum, dirId, "\pFRAGTHRQ", ostUnknown, ftGenericDocumentPC);
if(!rc)
@@ -303,7 +303,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
}
printf("\tFile name = \"%s\", size = %d, rc = %d, wRc = %d, cRc = %d\n",
printf("\tFile name = \"%s\", size = %ld, rc = %d, wRc = %d, cRc = %d\n",
"FRAGSIXQ",
twoAndThreeQuartCluster,
rc,

View File

@@ -43,14 +43,14 @@ void GetOsInfo()
printf("OS information:\n");
rc = Gestalt(gestaltAUXVersion, &gestaltResponse);
if(!rc) { printf("Running under A/UX version 0x%08X\n", gestaltResponse); }
if(!rc) { printf("Running under A/UX version 0x%08lX\n", gestaltResponse); }
else
{
rc = Gestalt(gestaltSystemVersion, &gestaltResponse);
if(rc) { printf("Could not get Mac OS version.\n"); }
else
{
printf("Running under Mac OS version %d.%d.%d",
printf("Running under Mac OS version %ld.%ld.%ld",
(gestaltResponse & 0xF00) >> 8,
(gestaltResponse & 0xF0) >> 4,
gestaltResponse & 0xF);
@@ -63,7 +63,7 @@ void GetOsInfo()
case 1: printf("Motorola 68k architecture."); break;
case 2: printf("PowerPC architecture."); break;
case 3: printf("x86 architecture."); break;
default: printf("unknown architecture code %d.", gestaltResponse); break;
default: printf("unknown architecture code %ld.", gestaltResponse); break;
}
}
printf("\n");

View File

@@ -62,8 +62,8 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
rc = Gestalt(gestaltFSAttr, &gestaltResponse);
if(!rc)
{
hfsPlusApis = gestaltResponse & (1 << gestaltHasHFSPlusAPIs);
bigVol = gestaltResponse & (1 << gestaltFSSupports2TBVols);
hfsPlusApis = (gestaltResponse & (1 << gestaltHasHFSPlusAPIs))!= 0;
bigVol = (gestaltResponse & (1 << gestaltFSSupports2TBVols))!=0;
}
if(!bigVol)
@@ -124,10 +124,10 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
printf("\tVolume name: %#s\n", str255);
printf("\t%llu allocation blocks in volume, %llu free\n", totalBlocks, freeBlocks);
printf("\t%llu bytes in volume, %llu free\n", totalBytes, freeBytes);
printf("\t%d bytes per allocation block.\n", *clusterSize);
printf("\tVolume created on 0x%08X\n", crDate);
printf("\tVolume last written on 0x%08X\n", lwDate);
printf("\tVolume last backed up on 0x%08X\n", bkDate);
printf("\t%lu bytes per allocation block.\n", *clusterSize);
printf("\tVolume created on 0x%08lX\n", crDate);
printf("\tVolume last written on 0x%08lX\n", lwDate);
printf("\tVolume last backed up on 0x%08lX\n", bkDate);
printf("\tFilesystem type: ");
switch(fsId)
{

View File

@@ -118,7 +118,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "HALFCLST", halfCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "HALFCLST", halfCluster, rc, wRc, cRc);
h = CreateFileA("QUARCLST", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -141,7 +141,7 @@ void Fragmentation(const char* path, size_t clusterSize)
}
printf(
"\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
"\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "QUARCLST", quarterCluster, rc, wRc, cRc);
h = CreateFileA("TWOCLST", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -163,7 +163,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "TWOCLST", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "TWOCLST", twoCluster, rc, wRc, cRc);
h = CreateFileA("TRQTCLST", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -185,7 +185,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n",
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n",
"TRQTCLST",
threeQuartersCluster,
rc,
@@ -212,7 +212,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n",
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n",
"TWTQCLST",
twoAndThreeQuartCluster,
rc,
@@ -239,7 +239,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "TWO1", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "TWO1", twoCluster, rc, wRc, cRc);
h = CreateFileA("TWO2", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -261,7 +261,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "TWO2", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "TWO2", twoCluster, rc, wRc, cRc);
h = CreateFileA("TWO3", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -287,7 +287,7 @@ void Fragmentation(const char* path, size_t clusterSize)
ret = DeleteFileA("TWO2");
if(!ret) { rc = GetLastError(); }
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n", "TWO3", twoCluster, rc, wRc, cRc);
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n", "TWO3", twoCluster, rc, wRc, cRc);
h = CreateFileA("FRAGTHRQ", dwFilePermissions, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
rc = 0;
@@ -316,7 +316,7 @@ void Fragmentation(const char* path, size_t clusterSize)
ret = DeleteFileA("TWO3");
if(!ret) { rc = GetLastError(); }
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n",
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n",
"FRAGTHRQ",
threeQuartersCluster,
rc,
@@ -343,7 +343,7 @@ void Fragmentation(const char* path, size_t clusterSize)
free(buffer);
}
printf("\tFile name = \"%s\", size = %d, rc = %lu, wRc = %lu, cRc = %lu\n",
printf("\tFile name = \"%s\", size = "SIZE_T_FORMAT", rc = %lu, wRc = %lu, cRc = %lu\n",
"FRAGSIXQ",
twoAndThreeQuartCluster,
rc,

View File

@@ -287,7 +287,7 @@ void GetVolumeInfo(const char* path, size_t* clusterSize)
*clusterSize = dwSectorsPerCluster * dwBytesPerSector;
printf("\tBytes per sector: %lu\n", dwBytesPerSector);
printf("\tSectors per cluster: %lu (%u bytes)\n", dwSectorsPerCluster, *clusterSize);
printf("\tSectors per cluster: %lu ("SIZE_T_FORMAT" bytes)\n", dwSectorsPerCluster, *clusterSize);
if(WinGetVersionExA)
{

View File

@@ -27,6 +27,9 @@ Contains 32-bit and 64-bit Windows declarations
Copyright (C) 2011-2021 Natalia Portillo
*****************************************************************************/
#pragma clang diagnostic push
#pragma ide diagnostic ignored "bugprone-reserved-identifier"
#ifndef AARU_FSTESTER_SETTER_WIN32_H
#define AARU_FSTESTER_SETTER_WIN32_H
@@ -57,4 +60,12 @@ static BOOL(WINAPI* WinGetVersionExA)(WIN_LPOSVERSIONINFOA);
static DWORD dwMaxNameSize = MAX_PATH + 1;
static DWORD dwFilePermissions = GENERIC_READ | GENERIC_WRITE;
#if defined(__aarch64__) || defined(_M_ARM64) || defined(__ia64__) || defined(_M_IA64) || defined(__x86_64__) || defined(__amd64) || defined(_M_AMD64) || defined(_M_X64)
#define SIZE_T_FORMAT "%llu"
#else
#define SIZE_T_FORMAT "%u"
#endif
#endif
#pragma clang diagnostic pop