Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 5baf677b authored by deuce's avatar deuce

Use -Wall and fix many of the resulting warnings (some of which are bugs)

parent 31aab79c
......@@ -68,7 +68,7 @@ endif
#
CFLAGS += -fPIC
LDFLAGS += -fPIC
CFLAGS += -O2 -L${LIBDIR} -I../xpdev
CFLAGS += -O2 -L${LIBDIR} -I../xpdev -Wall
ifeq ($(OS),Darwin)
CFLAGS += -D__unix__
LDFLAGS += $(CFLAGS) -dynamiclib -single_module
......
......@@ -84,7 +84,7 @@ ODAPIDEF BOOL ODCALL od_puttext(INT nLeft, INT nTop, INT nRight, INT nBottom,
INT nRowBytes = nRowLength * 2;
char *pchTest;
char *pchMemory;
char *pBuffer;
char *pBuffer=NULL;
char *pchScreenBlock;
INT nBlockRow = 0;
INT nOutRow;
......@@ -155,7 +155,8 @@ ODAPIDEF BOOL ODCALL od_puttext(INT nLeft, INT nTop, INT nRight, INT nBottom,
pBlock))
{
od_control.od_error = ERR_PARAMETER;
free(pBuffer);
if(pBuffer)
free(pBuffer);
OD_API_EXIT();
return(FALSE);
}
......
......@@ -1834,7 +1834,7 @@ tODResult ODComOpenFromExistingHandle(tPortHandle hPort,
#ifdef INCLUDE_SOCKET_COM
if(pPortInfo->Method == kComMethodSocket) {
int delay=FALSE;
socklen_t delay=FALSE;
pPortInfo->socket = dwExistingHandle;
......
......@@ -92,7 +92,7 @@ typedef enum
kComMethodWin32,
kComMethodDoor32,
kComMethodSocket,
kComMethodStdIO,
kComMethodStdIO
} tComMethod;
/* Serial I/O event types. */
......
......@@ -484,6 +484,10 @@ static void ODEditDrawAreaLine(tEditInstance *pEditInstance,
od_disp(ODEditBufferGetCharacter(pEditInstance, unBufferLine, 0),
unLineLength, TRUE);
}
else
{
unLineLength = 0;
}
/* If right edge of edit area aligns with the right edge of the screen. */
if(pEditInstance->pUserOptions->nAreaRight == OD_SCREEN_WIDTH)
......@@ -1466,6 +1470,7 @@ static void ODEditSetBreakSequence(tEditInstance *pEditInstance,
{
/* This should never happen: an invalid end of line sequence was */
/* passed in. */
pszSequence = NULL;
ASSERT(FALSE);
}
......
......@@ -150,12 +150,14 @@ tODKeySequence aKeySequences[] =
/* Current control sequence received state. */
static char szCurrentSequence[SEQUENCE_BUFFER_SIZE] = "";
#if 0 // Unused...
static tODTimer SequenceFailTimer;
static BOOL bSequenceFromRemote;
static int nMatchedSequence = NO_MATCH;
static BOOL bTimerActive = FALSE;
#endif
static BOOL bDoorwaySequence = FALSE;
static BOOL bDoorwaySequencePending = FALSE;
static BOOL bTimerActive = FALSE;
/* Local private function prototypes. */
static int ODGetCodeIfLongest(WORD wFlags);
......@@ -414,11 +416,9 @@ static int ODLongestFullCode(WORD wFlags)
*/
static int ODHaveStartOfSequence(WORD wFlags)
{
int CurrLen=0;
int seqlen1;
int seqlen2;
int i;
int retval=NO_MATCH;;
if(wFlags & GETIN_RAW)
return(FALSE);
......
......@@ -1550,7 +1550,7 @@ static BOOL ODInitReadSFDoorsDAT(void)
/* Line 15: User's login time. */
if(fgets((char *)apszDropFileInfo[2],255,pfDropFile)==NULL) return(FALSE);
sprintf(od_control.user_logintime, "%02.2d:%02.2d",
sprintf(od_control.user_logintime, "%02d:%02d",
atoi((char *)apszDropFileInfo[2]) % 60,
atoi((char *)apszDropFileInfo[2]) / 60);
......
......@@ -112,10 +112,12 @@ static void ODKrnlTimeUpdate(void);
static void ODKrnlChatCleanup(void);
static void ODKrnlChatMode(void);
#ifdef ODPLAT_NIX
#ifdef USE_KERNEL_SIGNAL
static void sig_run_kernel(int sig);
static void sig_get_char(int sig);
static void sig_no_carrier(int sig);
#endif
#endif
/* Functions specific to the multithreaded implementation of the kernel. */
#ifdef OD_MULTITHREADED
......@@ -179,8 +181,10 @@ tODResult ODKrnlInitialize(void)
{
#ifdef ODPLAT_NIX
sigset_t block;
#ifdef USE_KERNEL_SIGNAL
struct sigaction act;
struct itimerval itv;
#endif
#endif
tODResult Result = kODRCSuccess;
......@@ -206,17 +210,16 @@ tODResult ODKrnlInitialize(void)
setitimer(ITIMER_REAL,&itv,NULL);
/* Make stdin signal driven. */
/* act.sa_handler=sig_get_char;
/* act.sa_flags=0;
/* sigemptyset(&(act.sa_mask));
/* sigaction(SIGIO,&act,NULL);
/*
/* /* Have SIGIO signals delivered to this process */
/* fcntl(0,F_SETOWN,getpid());
/*
/* /* Enable SIGIO when read possible on stdin */
/* fcntl(0,F_SETFL,fcntl(0,F_GETFL)|O_ASYNC); */
/*/
// act.sa_handler=sig_get_char;
// act.sa_flags=0;
// sigemptyset(&(act.sa_mask));
// sigaction(SIGIO,&act,NULL);
//
// /* Have SIGIO signals delivered to this process */
// fcntl(0,F_SETOWN,getpid());
//
// /* Enable SIGIO when read possible on stdin */
// fcntl(0,F_SETFL,fcntl(0,F_GETFL)|O_ASYNC);
/* Make sure SIGHUP, SIGALRM, and SIGIO are unblocked */
sigemptyset(&block);
......@@ -343,10 +346,12 @@ void ODKrnlShutdown(void)
ODAPIDEF void ODCALL od_kernel(void)
{
#ifndef OD_MULTITHREADED
char ch;
#ifdef ODPLAT_DOS
WORD wKey;
BYTE btShiftStatus;
char ch;
char *pszShellName;
#endif
BOOL bCarrier;
#endif /* OD_MULTITHREADED */
......@@ -1629,6 +1634,7 @@ static void ODKrnlChatCleanup(void)
}
#ifdef ODPLAT_NIX
#ifdef USE_KERNEL_SIGNAL
/* ----------------------------------------------------------------------------
* sig_run_kernel(sig) *** PRIVATE FUNCTION ***
*
......@@ -1657,7 +1663,6 @@ static void sig_get_char(int sig)
}
}
#ifdef USE_KERNEL_SIGNAL
static void sig_no_carrier(int sig)
{
if(od_control.baud != 0 && )
......
......@@ -105,7 +105,7 @@ ODAPIDEF BOOL ODCALL od_log_open()
ptmTimeRecord = localtime(&nUnixTime);
/* Print logfile tear line. */
fprintf(logfile_pointer, "\n---------- %s %02.2d %s %02.2d, %s\n",
fprintf(logfile_pointer, "\n---------- %s %02d %s %02d, %s\n",
od_control.od_day[ptmTimeRecord->tm_wday],
ptmTimeRecord->tm_mday,
od_control.od_month[ptmTimeRecord->tm_mon],
......@@ -201,11 +201,11 @@ ODAPIDEF BOOL ODCALL od_log_write(char *pszMessage)
/* Determine which logfile format string to use. */
if(ptmTimeRecord->tm_hour<10)
{
pszFormat=(char *)"> %1.1d:%02.2d:%02.2d %s\n";
pszFormat=(char *)"> %1.1d:%02d:%02d %s\n";
}
else
{
pszFormat=(char *)"> %2.2d:%02.2d:%02.2d %s\n";
pszFormat=(char *)"> %2.2d:%02d:%02d %s\n";
}
/* Write a line to the logfile. */
......
......@@ -63,6 +63,7 @@
#include <glob.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include "ODGen.h"
#include "ODCore.h"
......@@ -579,7 +580,7 @@ void ODTimerStart(tODTimer *pTimer, tODMilliSec Duration)
#ifdef ODPLAT_NIX
gettimeofday(&tv,NULL);
pTimer->Start=(long long)tv.tv_sec*1000+tv.tv_usec/1000;
pTimer->Start=tv.tv_sec*1000+tv.tv_usec/1000;
pTimer->Duration = Duration;
#endif
}
......@@ -597,11 +598,6 @@ void ODTimerStart(tODTimer *pTimer, tODMilliSec Duration)
*/
BOOL ODTimerElapsed(tODTimer *pTimer)
{
#ifdef ODPLAT_NIX
struct timeval tv;
struct timeval end;
#endif
ASSERT(pTimer != NULL);
#ifdef ODPLAT_DOS
......@@ -672,7 +668,7 @@ tODMilliSec ODTimerLeft(tODTimer *pTimer)
{
#ifdef ODPLAT_NIX
struct timeval tv;
long long int nowtick;
time_t nowtick;
#endif
ASSERT(pTimer != NULL);
......@@ -694,10 +690,10 @@ tODMilliSec ODTimerLeft(tODTimer *pTimer)
}
#elif defined(ODPLAT_NIX)
gettimeofday(&tv,NULL);
nowtick=(long long)tv.tv_sec*1000+(tv.tv_usec/1000);
if((long long)pTimer->Start+pTimer->Duration <= nowtick)
nowtick=tv.tv_sec*1000+(tv.tv_usec/1000);
if(pTimer->Start+pTimer->Duration <= nowtick)
return(0);
return((tODMilliSec)((long long)pTimer->Start + pTimer->Duration - nowtick));
return((tODMilliSec)(pTimer->Start + pTimer->Duration - nowtick));
#else /* !ODPLAT_DOS */
{
tODMilliSec Now;
......@@ -738,8 +734,8 @@ ODAPIDEF void ODCALL od_sleep(tODMilliSec Milliseconds)
#ifdef ODPLAT_NIX
struct timeval tv;
struct timeval start;
long long started;
long long left
time_t started;
time_t left
#endif
/* Log function entry if running in trace mode. */
TRACE(TRACE_API, "od_sleep()");
......@@ -840,7 +836,9 @@ typedef struct
/* Directory access private function prototypes. */
#if defined(ODPLAT_DOS) || defined(ODPLAT_WIN32)
static time_t DOSToCTime(WORD wDate, WORD wTime);
#endif
#ifdef ODPLAT_DOS
static INT ODDirDOSFindFirst(CONST char *pszPath, tDOSDirEntry *pBlock,
WORD wAttributes);
......@@ -1130,6 +1128,7 @@ void ODDirClose(tODDirHandle hDir)
}
#if defined(ODPLAT_DOS) || defined(ODPLAT_WIN32)
/* ----------------------------------------------------------------------------
* DOSToCTime() *** PRIVATE FUNCTION ***
*
......@@ -1154,6 +1153,7 @@ static time_t DOSToCTime(WORD wDate, WORD wTime)
return(mktime(&TimeStruct));
}
#endif
/* MS-DOS specific functions for directory access. */
......
......@@ -72,7 +72,7 @@ typedef struct
clock_t Start;
clock_t Duration;
#elif defined(ODPLAT_NIX)
long long Start;
time_t Start;
tODMilliSec Duration;
#else /* !ODPLAT_DOS */
tODMilliSec Start;
......
......@@ -93,9 +93,7 @@
/* Private variables used by the screen I/O functions. */
/* Segment address of video buffer. */
#if defined(ODPLAT_DOS) || defined(ODPLAT_NIX)
static WORD wBufferSegment;
static void *pAllocatedBufferMemory;
#endif /* ODPLAT_DOS */
......@@ -118,8 +116,12 @@ static BYTE btCurrentAttribute;
/* Is scrolling enabled. */
static BOOL bScrollEnabled;
#ifdef ODPLAT_DOS
/* Segment address of video buffer. */
static WORD wBufferSegment;
/* Display page to use. */
static BYTE btDisplayPage;
#endif
/* Is cursor currently on. */
static BYTE bCaretOn;
......@@ -944,8 +946,6 @@ tODResult ODScrnInitialize(void)
BOOL bClear = TRUE;
#if defined(ODPLAT_DOS) || defined(ODPLAT_NIX)
BYTE btDisplayMode;
/* In silent mode, we perform all output in a block of memory that is */
/* never displayed. */
/* *nix is always in "silent mode" */
......@@ -969,6 +969,8 @@ tODResult ODScrnInitialize(void)
}
else
{
BYTE btDisplayMode;
/* Get current video mode. */
ASM push si
ASM push di
......
......@@ -60,6 +60,7 @@
#include <signal.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#endif
#include "ODCore.h"
#include "ODGen.h"
......@@ -155,6 +156,11 @@ static void savevect(void);
#endif /* ODPLAT_DOS */
#ifdef ODPLAT_NIX
/* Location function prototypes. */
int _spawnvpe(int nModeFlag, char *pszPath, char *papszArgs[],
char *papszEnviron[]);
#endif /* ODPLAT_NIX */
/* ----------------------------------------------------------------------------
* od_spawn()
......@@ -225,8 +231,6 @@ ODAPIDEF BOOL ODCALL od_spawn(char *pszCommandLine)
#ifdef ODPLAT_NIX
sigset_t block;
struct itimerval itv;
struct sigaction act;
int retval;
/* Suspend kernel */
......@@ -278,7 +282,7 @@ ODAPIDEF INT16 ODCALL od_spawnvpe(INT16 nModeFlag, char *pszPath,
#ifdef ODPLAT_WIN32
void *pWindow;
#endif /* ODPLAT_WIN32 */
#if defined(ODPLAT_DOS) || defined(ODPLAT_NIX)
#ifdef ODPLAT_DOS
char *pszDir;
BYTE *abtScreenBuffer;
INT nDrive;
......
......@@ -55,7 +55,7 @@ typedef enum
kODRCTimeout,
kODRCSafeFailure,
kODRCUnrecoverableFailure,
kODRCUnsupported,
kODRCUnsupported
} tODResult;
/* Callback function types. */
......
......@@ -141,7 +141,7 @@ char *ODStringPascalToC(char *pszCString, char *psPascalString,
if(*(BYTE *)psPascalString <= btMaxLength)
{
memcpy(pszCString, (char *)psPascalString + 1, *psPascalString);
pszCString[*psPascalString] = '\0';
pszCString[(int)psPascalString[0]] = '\0';
}
else
{
......
......@@ -107,7 +107,7 @@ char shell_window_text=0x1b; /* Colour of text in DOS shell window */
char cursor_window; /* FULL-SCREEN CHAT INTERNAL VARIABLES */
int cursor_window; /* FULL-SCREEN CHAT INTERNAL VARIABLES */
char current_word[2][81];
int word_length[2];
int cursor_col[2];
......
......@@ -346,7 +346,7 @@ void PlayGame(void)
tHighScoreRecord ScoreRecord;
FILE *pfFile;
tHighScoreFile HighScores;
int nBackup;
int nBackup=0;
clock_t StartClock;
/* Clear the Screen */
......@@ -543,7 +543,7 @@ void SpaceRight(int nColumns)
if(od_control.user_ansi)
{
/* Move cursor right using ESC[nC control sequence */
sprintf(szSequence, "\x1b[%02.2dC", nColumns);
sprintf(szSequence, "\x1b[%02dC", nColumns);
od_disp_emu(szSequence, TRUE);
}
......@@ -561,7 +561,7 @@ void MoveLeft(int nColumns)
{
/* Move cursor left using ESC[nD control sequence */
char szSequence[6];
sprintf(szSequence, "\x1b[%02.2dD", nColumns);
sprintf(szSequence, "\x1b[%02dD", nColumns);
od_disp_emu(szSequence, TRUE);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment