Skip to content

Commit

Permalink
Merge pull request #72 from DidierMalenfant/devel
Browse files Browse the repository at this point in the history
Fixed some compilation warnings
  • Loading branch information
t-w authored Feb 8, 2024
2 parents 1132750 + 88fe320 commit 320d1ae
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 51 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ if ( NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC" )
)
endif()

if ("${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang")
message ( STATUS "Setting additional clang options/checks" )
add_compile_options (
-Wno-gnu-statement-expression-from-macro-expansion
)
endif()

option ( ADFLIB_ENABLE_ADDRESS_SANITIZER "Enable address sanitizer" OFF )

Expand Down
10 changes: 5 additions & 5 deletions examples/adf_bitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ int main ( int argc,
command = COMMAND_REBUILD;
else if ( strcmp ( argv[1], "show" ) == 0 )
command = COMMAND_SHOW;
else if ( strcmp ( argv[1], "help" ) == 0 )
else if ( strcmp ( argv[1], "help" ) == 0 ) {
usage();
return 0;
}
else {
fprintf ( stderr, "\nUnknown command '%s' "
"(use 'adf_bitmap help' for usage info)\n\n",
Expand Down Expand Up @@ -174,7 +176,7 @@ int show_block_allocation_bitmap ( struct AdfVolume * const vol )

printf ( "\nBlock allocation bitmap valid: %s\n",
rb.bmFlag == BM_VALID ? "yes" : "No!" );

/* Check root bm pages */
unsigned nerrors = 0,
nblocks_free = 0,
Expand Down Expand Up @@ -221,7 +223,6 @@ int show_block_allocation_bitmap ( struct AdfVolume * const vol )

/* show bmExt blocks */
SECTNUM bmExtBlkPtr = rb.bmExt;
unsigned bmExt_i = 0;
while ( bmExtBlkPtr != 0 ) {
struct bBitmapExtBlock bmExtBlk;
RETCODE rc = adfReadBitmapExtBlock ( vol, bmExtBlkPtr, &bmExtBlk );
Expand Down Expand Up @@ -273,7 +274,6 @@ int show_block_allocation_bitmap ( struct AdfVolume * const vol )
}

bmExtBlkPtr = bmExtBlk.nextBlock;
bmExt_i++;
}

/* show block statistics */
Expand All @@ -288,7 +288,7 @@ int show_block_allocation_bitmap ( struct AdfVolume * const vol )
"(or bitmap ext.) blocks could not be read\n"
" so the numbers above are not fully accurate "
"(exclude data from the unchecked bitmap blocks!)\n", nerrors );
return ( nerrors > 0 ) ? 1 : 0;
return ( nerrors > 0 ) ? 1 : 0;
}


Expand Down
6 changes: 3 additions & 3 deletions examples/adf_show_metadata_volume.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ void show_volume_metadata ( struct AdfVolume * const vol )
if ( adfReadBootBlock ( vol, &bblock ) != RC_OK ) {
fprintf ( stderr, "Error reading rootblock\n");
return;
}
}
show_bootblock ( &bblock, false );

struct bRootBlock rblock;
uint32_t root_block_sector = adfVolCalcRootBlk ( vol );
SECTNUM root_block_sector = adfVolCalcRootBlk ( vol );
printf ("\nRoot block sector:\t%u\n", root_block_sector );

if ( adfReadRootBlock ( vol, root_block_sector, &rblock ) != RC_OK ) {
if ( adfReadRootBlock ( vol, (uint32_t)root_block_sector, &rblock ) != RC_OK ) {
fprintf ( stderr, "Error reading rootblock at sector %u.\n", root_block_sector );
return;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/unadf.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct AdfList *file_list = NULL;

/* prototypes */
void parse_args(int argc, char *argv[]);
void help();
void help(void);
void print_device(struct AdfDevice *dev);
void print_volume(struct AdfVolume * vol);
void print_tree(struct AdfList *node, char *path);
Expand Down Expand Up @@ -227,7 +227,7 @@ void parse_args(int argc, char *argv[]) {
}
}

void help() {
void help(void) {
fprintf(stderr,
"unadf [-lrcsmpw] [-v n] [-d extractdir] dumpname.adf [files-with-path]\n"
" -l : lists root directory contents\n"
Expand Down
38 changes: 19 additions & 19 deletions src/adf_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* along with Foobar; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
*/

#include "adf_cache.h"

Expand Down Expand Up @@ -103,17 +103,17 @@ struct AdfList * adfGetDirEntCache ( struct AdfVolume * const vol,
}
entry->size = (uint32_t) caEntry.size;
entry->access = (int32_t) caEntry.protect;
adfDays2Date( caEntry.days, &(entry->year), &(entry->month),
adfDays2Date( caEntry.days, &(entry->year), &(entry->month),
&(entry->days) );
entry->hour = caEntry.mins/60;
entry->mins = caEntry.mins%60;
entry->secs = caEntry.ticks/50;

/* add it into the linked list */
if (head==NULL)
head = cell = newCell(NULL, (void*)entry);
head = cell = newCell(NULL, (void*)entry);
else
cell = newCell(cell, (void*)entry);
cell = newCell(cell, (void*)entry);

if (cell==NULL) {
adfFreeEntry(entry);
Expand All @@ -128,8 +128,8 @@ struct AdfList * adfGetDirEntCache ( struct AdfVolume * const vol,
}
nSect = dirc.nextDirC;
}while (nSect!=0);
return head;

return head;
}


Expand Down Expand Up @@ -193,7 +193,7 @@ RETCODE adfGetCacheEntry ( const struct bDirCacheBlock * const dirc,
/*printf("cEntry->nLen %d cEntry->cLen %d %s\n",cEntry->nLen,cEntry->cLen,cEntry->name);*/
*p = ptr+24+cEntry->nLen+1+cEntry->cLen;

/* the starting offset of each record must be even (68000 constraint) */
/* the starting offset of each record must be even (68000 constraint) */
if ((*p%2)!=0)
*p=(*p)+1;

Expand Down Expand Up @@ -229,7 +229,7 @@ int adfPutCacheEntry ( struct bDirCacheBlock * const dirc,
memcpy(dirc->records+ptr+18,&(cEntry->mins),2);
memcpy(dirc->records+ptr+20,&(cEntry->ticks),2);
#endif
dirc->records[ptr+22] =(signed char)cEntry->type;
dirc->records[ptr+22] =(uint8_t)cEntry->type;

dirc->records[ptr+23] = cEntry->nLen;
memcpy(dirc->records+ptr+24, cEntry->name, cEntry->nLen);
Expand All @@ -247,7 +247,7 @@ int adfPutCacheEntry ( struct bDirCacheBlock * const dirc,
return l+1;
}

/* ptr%2 must be == 0, if l%2==0, (ptr+l)%2==0 */
/* ptr%2 must be == 0, if l%2==0, (ptr+l)%2==0 */
}


Expand Down Expand Up @@ -348,8 +348,8 @@ RETCODE adfDelFromCache ( struct AdfVolume * const vol,
return rc;
}
else {
/* dirc.recordsNb ==1 or == 0 , prevSect!=-1 :
* the only record in this dirc block and a previous dirc block exists
/* dirc.recordsNb ==1 or == 0 , prevSect!=-1 :
* the only record in this dirc block and a previous dirc block exists
*/
adfSetBlockFree(vol, dirc.headerKey);

Expand Down Expand Up @@ -399,7 +399,7 @@ RETCODE adfAddInCache ( struct AdfVolume * const vol,
entryLen = adfEntry2CacheEntry(entry, &newEntry);
/*printf("adfAddInCache--%4ld %2d %6ld %8lx %4d %2d:%02d:%02d %30s %22s\n",
newEntry.header, newEntry.type, newEntry.size, newEntry.protect,
newEntry.days, newEntry.mins/60, newEntry.mins%60,
newEntry.days, newEntry.mins/60, newEntry.mins%60,
newEntry.ticks/50,
newEntry.name, newEntry.comm);
*/
Expand All @@ -418,13 +418,13 @@ RETCODE adfAddInCache ( struct AdfVolume * const vol,

/*printf("*%4ld %2d %6ld %8lx %4d %2d:%02d:%02d %30s %22s\n",
caEntry.header, caEntry.type, caEntry.size, caEntry.protect,
caEntry.days, caEntry.mins/60, caEntry.mins%60,
caEntry.days, caEntry.mins/60, caEntry.mins%60,
caEntry.ticks/50,
caEntry.name, caEntry.comm);
*/
n++;
}

/* if (offset+entryLen<=488) {
adfPutCacheEntry(&dirc, &offset, &newEntry);
dirc.recordsNb++;
Expand Down Expand Up @@ -528,8 +528,8 @@ RETCODE adfUpdateCache ( struct AdfVolume * const vol,
}
else if (oLen>nLen) {
/*puts("oLen>nLen");*/
/* the new record is shorter, write it,
* then shift down the following records
/* the new record is shorter, write it,
* then shift down the following records
*/
adfPutCacheEntry(&dirc, &oldOffset, &newEntry);
for(i=oldOffset+nLen; i<(488-sLen); i++)
Expand Down Expand Up @@ -605,7 +605,7 @@ RETCODE adfCreateEmptyCache ( struct AdfVolume * const vol,
(*adfEnv.wFct)("adfCreateEmptyCache : unknown secType");
/*printf("secType=%ld\n",parent->secType);*/
}

dirc.recordsNb = 0;
dirc.nextDirC = 0;

Expand Down Expand Up @@ -655,9 +655,9 @@ RETCODE adfWriteDirCBlock ( struct AdfVolume * const vol,
{
uint8_t buf[LOGICAL_BLOCK_SIZE];
uint32_t newSum;

dirc->type = T_DIRC;
dirc->headerKey = nSect;
dirc->headerKey = nSect;

memcpy(buf, dirc, LOGICAL_BLOCK_SIZE);
#ifdef LITT_ENDIAN
Expand Down
10 changes: 5 additions & 5 deletions src/adf_env.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void checkInternals(void);
* adfInitEnv
*
*/
void adfEnvInitDefault()
void adfEnvInitDefault(void)
{
checkInternals();

Expand All @@ -71,7 +71,7 @@ void adfEnvInitDefault()
adfEnv.notifyFct = Changed;
adfEnv.rwhAccess = rwHeadAccess;
adfEnv.progressBar = progressBar;

adfEnv.useDirCache = FALSE;
adfEnv.useRWAccess = FALSE;
adfEnv.useNotify = FALSE;
Expand All @@ -91,7 +91,7 @@ void adfEnvInitDefault()
* adfEnvCleanUp
*
*/
void adfEnvCleanUp()
void adfEnvCleanUp(void)
{
free(adfEnv.nativeFct);
}
Expand Down Expand Up @@ -168,7 +168,7 @@ void adfSetEnvFct ( const AdfLogFct eFct,
* adfGetVersionNumber
*
*/
char* adfGetVersionNumber()
char* adfGetVersionNumber(void)
{
return(ADFLIB_VERSION);
}
Expand All @@ -178,7 +178,7 @@ char* adfGetVersionNumber()
* adfGetVersionDate
*
*/
char* adfGetVersionDate()
char* adfGetVersionDate(void)
{
return(ADFLIB_DATE);
}
Expand Down
10 changes: 5 additions & 5 deletions src/adf_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* adf_env.h
*
* $Id$
*
*
* This file is part of ADFLib.
*
* ADFLib is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -70,17 +70,17 @@ struct AdfEnv {
};


PREFIX void adfEnvInitDefault();
PREFIX void adfEnvInitDefault(void);

PREFIX void adfSetEnvFct ( const AdfLogFct eFct,
const AdfLogFct wFct,
const AdfLogFct vFct,
const AdfNotifyFct notifyFct );

PREFIX void adfEnvCleanUp();
PREFIX void adfEnvCleanUp(void);
PREFIX void adfChgEnvProp(int prop, void *new);
PREFIX char* adfGetVersionNumber();
PREFIX char* adfGetVersionDate();
PREFIX char* adfGetVersionNumber(void);
PREFIX char* adfGetVersionDate(void);

PREFIX extern struct AdfEnv adfEnv;

Expand Down
Loading

0 comments on commit 320d1ae

Please sign in to comment.