mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-14 08:01:38 +01:00
turned on -Wall and fixed errors/warnings it reported
This commit is contained in:
parent
587159f5d7
commit
c6b28e9416
10 changed files with 41 additions and 38 deletions
|
@ -1,5 +1,4 @@
|
|||
# -*- mode: Makefile -*-
|
||||
|
||||
# -*- mode: Makefile; compile-command: "../../scripts/ndkbuild.sh"; -*-
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
@ -18,7 +17,6 @@ local_DEFINES += \
|
|||
-DRELAY_NAME_DEFAULT=\"10.0.2.2\" \
|
||||
-DRELAY_PORT_DEFAULT=10999 \
|
||||
-DXWFEATURE_TURNCHANGENOTIFY \
|
||||
-DXWFEATURE_SEARCHLIMIT \
|
||||
-DKEYBOARD_NAV \
|
||||
-DKEY_SUPPORT \
|
||||
-DPOINTER_SUPPORT \
|
||||
|
@ -57,7 +55,7 @@ common_SRC_FILES += \
|
|||
$(COMMON_PATH)/movestak.c \
|
||||
|
||||
|
||||
LOCAL_CFLAGS+=$(local_C_INCLUDES) $(local_DEFINES)
|
||||
LOCAL_CFLAGS+=$(local_C_INCLUDES) $(local_DEFINES) -Wall
|
||||
LOCAL_SRC_FILES := $(linux_SRC_FILES) $(local_SRC_FILES) $(common_SRC_FILES)
|
||||
LOCAL_MODULE := xwjni
|
||||
LOCAL_LDLIBS := -L${SYSROOT}/usr/lib -llog -lz
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "anddict.h"
|
||||
#include "xptypes.h"
|
||||
#include "dictnry.h"
|
||||
#include "dictnryp.h"
|
||||
#include "strutils.h"
|
||||
#include "andutils.h"
|
||||
#include "utilwrapper.h"
|
||||
|
@ -87,9 +88,7 @@ andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8** ptrp )
|
|||
jobject bitmap = NULL;
|
||||
|
||||
if ( nCols > 0 ) {
|
||||
XP_U8* savedDest;
|
||||
XP_U8 nRows = *ptr++;
|
||||
XP_U16 rowBytes = (nCols+7) / 8;
|
||||
XP_U8 srcByte = 0;
|
||||
XP_U8 nBits;
|
||||
XP_U16 ii;
|
||||
|
@ -101,8 +100,7 @@ andMakeBitmap( AndDictionaryCtxt* ctxt, XP_U8** ptrp )
|
|||
nBits = nRows * nCols;
|
||||
for ( ii = 0; ii < nBits; ++ii ) {
|
||||
XP_U8 srcBitIndex = ii % 8;
|
||||
XP_U8 destBitIndex = (ii % nCols) % 8;
|
||||
XP_U8 srcMask, bit;
|
||||
XP_U8 srcMask;
|
||||
|
||||
if ( srcBitIndex == 0 ) {
|
||||
srcByte = *ptr++;
|
||||
|
@ -402,9 +400,6 @@ and_dictionary_make_empty( MPFORMAL_NOCOMMA )
|
|||
DictionaryCtxt*
|
||||
makeDict( MPFORMAL JNIEnv *env, JNIUtilCtxt* jniutil, jbyteArray jbytes )
|
||||
{
|
||||
XP_Bool formatOk = XP_TRUE;
|
||||
XP_Bool isUTF8 = XP_FALSE;
|
||||
XP_U16 charSize;
|
||||
AndDictionaryCtxt* anddict = NULL;
|
||||
|
||||
jsize len = (*env)->GetArrayLength( env, jbytes );
|
||||
|
@ -426,6 +421,5 @@ makeDict( MPFORMAL JNIEnv *env, JNIUtilCtxt* jniutil, jbyteArray jbytes )
|
|||
parseDict( anddict, localBytes, len );
|
||||
setBlankTile( &anddict->super );
|
||||
|
||||
err:
|
||||
return (DictionaryCtxt*)anddict;
|
||||
return (DictionaryCtxt*)anddict;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value )
|
|||
return success;
|
||||
}
|
||||
|
||||
bool
|
||||
void
|
||||
getString( JNIEnv* env, jobject obj, const char* name, XP_UCHAR* buf,
|
||||
int bufLen )
|
||||
{
|
||||
|
@ -311,8 +311,6 @@ setJAddrRec( JNIEnv* env, jobject jaddr, const CommsAddrRec* addr )
|
|||
void
|
||||
getJAddrRec( JNIEnv* env, CommsAddrRec* addr, jobject jaddr )
|
||||
{
|
||||
XP_UCHAR buf[256];
|
||||
|
||||
addr->conType = jenumFieldToInt( env, jaddr, "conType",
|
||||
"org/eehouse/android/xw4/jni/"
|
||||
"CommsAddrRec$CommsConnType" );
|
||||
|
|
|
@ -7,17 +7,11 @@
|
|||
|
||||
#include "comtypes.h"
|
||||
#include "comms.h"
|
||||
#include "mempool.h"
|
||||
#include "dictnry.h"
|
||||
|
||||
#include "andglobals.h"
|
||||
|
||||
|
||||
XP_U32 and_ntohl(XP_U32 l);
|
||||
XP_U16 and_ntohs(XP_U16 s);
|
||||
XP_U32 and_htonl(XP_U32 l);
|
||||
XP_U16 and_htons(XP_U16 s);
|
||||
|
||||
/* callback for streams */
|
||||
void and_send_on_close( XWStreamCtxt* stream, void* closure );
|
||||
XWStreamCtxt* and_empty_stream( MPFORMAL AndGlobals* globals );
|
||||
|
@ -27,7 +21,7 @@ void setInt( JNIEnv* env, jobject obj, const char* name, int value );
|
|||
bool getBool( JNIEnv* env, jobject obj, const char* name );
|
||||
bool setBool( JNIEnv* env, jobject obj, const char* name, bool value );
|
||||
bool setString( JNIEnv* env, jobject obj, const char* name, const XP_UCHAR* value );
|
||||
bool getString( JNIEnv* env, jobject jlp, const char* name, XP_UCHAR* buf,
|
||||
void getString( JNIEnv* env, jobject jlp, const char* name, XP_UCHAR* buf,
|
||||
int bufLen );
|
||||
bool getObject( JNIEnv* env, jobject obj, const char* name, const char* sig,
|
||||
jobject* ret );
|
||||
|
|
|
@ -279,7 +279,7 @@ and_draw_trayBegin( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner,
|
|||
jboolean result = (*env)->CallBooleanMethod( env, draw->jdraw, mid,
|
||||
jrect, owner, (jint)dfs );
|
||||
|
||||
return XP_TRUE;
|
||||
return result;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include <jni.h>
|
||||
|
||||
#include "comtypes.h"
|
||||
#include "utilwrapper.h"
|
||||
#include "anddict.h"
|
||||
#include "andutils.h"
|
||||
|
@ -143,6 +144,7 @@ static XP_Bool
|
|||
and_util_askPassword( XW_UtilCtxt* uc, const XP_UCHAR* name,
|
||||
XP_UCHAR* buf, XP_U16* len )
|
||||
{
|
||||
return XP_FALSE;;
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +189,7 @@ static XP_Bool
|
|||
and_util_hiliteCell( XW_UtilCtxt* uc, XP_U16 col, XP_U16 row )
|
||||
{
|
||||
/* don't log; this is getting called a lot */
|
||||
return XP_TRUE; /* means keep going */
|
||||
}
|
||||
|
||||
|
||||
|
@ -303,6 +306,7 @@ and_util_warnIllegalWord( XW_UtilCtxt* uc, BadWordInfo* bwi,
|
|||
XP_U16 turn, XP_Bool turnLost )
|
||||
{
|
||||
LOG_FUNC();
|
||||
return XP_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -330,6 +334,7 @@ static XP_Bool
|
|||
and_util_getTraySearchLimits(XW_UtilCtxt* uc, XP_U16* min, XP_U16* max )
|
||||
{
|
||||
LOG_FUNC();
|
||||
foobar; /* this should not be compiling */
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,7 @@ and_xport_send( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr,
|
|||
const char* sig = "([BLorg/eehouse/android/xw4/jni/CommsAddrRec;)I";
|
||||
jmethodID mid = getMethodID( env, aprocs->jxport, "transportSend", sig );
|
||||
|
||||
jbyteArray jbytes = makeByteArray( env, len, buf );
|
||||
jbyteArray jbytes = makeByteArray( env, len, (jbyte*)buf );
|
||||
jobject jaddr = makeJAddr( env, addr );
|
||||
|
||||
result = (*env)->CallIntMethod( env, aprocs->jxport, mid,
|
||||
|
|
|
@ -95,6 +95,11 @@ void and_assert( const char* test, int line, const char* file, const char* func
|
|||
#define XP_WARNF(...)
|
||||
#endif
|
||||
|
||||
XP_U32 and_ntohl(XP_U32 l);
|
||||
XP_U16 and_ntohs(XP_U16 s);
|
||||
XP_U32 and_htonl(XP_U32 l);
|
||||
XP_U16 and_htons(XP_U16 s);
|
||||
|
||||
#define XP_NTOHL(l) and_ntohl(l)
|
||||
#define XP_NTOHS(s) and_ntohs(s)
|
||||
#define XP_HTONL(l) and_htonl(l)
|
||||
|
|
|
@ -258,12 +258,15 @@ typedef struct _JNIState {
|
|||
JNIState* state = (JNIState*)gamePtr; \
|
||||
MPSLOT; \
|
||||
MPASSIGN( mpool, state->mpool); \
|
||||
AndGlobals* globals = &state->globals; \
|
||||
/* if reentrant must be from same thread */ \
|
||||
XP_ASSERT( state->env == 0 || state->env == env ); \
|
||||
JNIEnv* _oldEnv = state->env; \
|
||||
state->env = env;
|
||||
|
||||
#define XWJNI_START_GLOBALS() \
|
||||
XWJNI_START() \
|
||||
AndGlobals* globals = &state->globals; \
|
||||
|
||||
#define XWJNI_END() \
|
||||
state->env = _oldEnv; \
|
||||
}
|
||||
|
@ -293,7 +296,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeNewGame
|
|||
jobject jniu, jobject j_draw, jobject j_cp, jobject j_procs,
|
||||
jbyteArray jDictBytes )
|
||||
{
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
CurGameInfo* gi = makeGI( MPPARM(mpool) env, j_gi );
|
||||
globals->gi = gi;
|
||||
globals->util = makeUtil( MPPARM(mpool) &state->env, j_util, gi,
|
||||
|
@ -357,7 +360,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1makeFromStream
|
|||
jobject jdraw, jobject jcp, jobject jprocs )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
|
||||
globals->gi = (CurGameInfo*)XP_CALLOC( mpool, sizeof(*globals->gi) );
|
||||
globals->util = makeUtil( MPPARM(mpool) &state->env,
|
||||
|
@ -401,7 +404,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1saveToStream
|
|||
( JNIEnv* env, jclass C, jint gamePtr, jobject jgi )
|
||||
{
|
||||
jbyteArray result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
|
||||
/* Use our copy of gi if none's provided. That's because only the caller
|
||||
knows if its gi should win -- user has changed game config -- or if
|
||||
|
@ -659,7 +662,11 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1requestHint
|
|||
jboolean result;
|
||||
XWJNI_START();
|
||||
XP_Bool tmpbool;
|
||||
result = board_requestHint( state->game.board, useLimits, &tmpbool );
|
||||
result = board_requestHint( state->game.board,
|
||||
#ifdef XWFEATURE_SEARCHLIMIT
|
||||
useLimits,
|
||||
#endif
|
||||
&tmpbool );
|
||||
/* If passed need to do workRemains[0] = tmpbool */
|
||||
if ( workRemains ) {
|
||||
jboolean* jelems = (*env)->GetBooleanArrayElements(env, workRemains, NULL );
|
||||
|
@ -675,7 +682,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_timerFired
|
|||
( JNIEnv* env, jclass C, jint gamePtr, jint why, jint when, jint handle )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XW_UtilCtxt* util = globals->util;
|
||||
result = utilTimerFired( util, why, handle );
|
||||
XWJNI_END();
|
||||
|
@ -687,7 +694,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_board_1formatRemainingTiles
|
|||
(JNIEnv* env, jclass C, jint gamePtr )
|
||||
{
|
||||
jstring result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = mem_stream_make( MPPARM(mpool) globals->vtMgr,
|
||||
NULL, 0, NULL );
|
||||
board_formatRemainingTiles( state->game.board, stream );
|
||||
|
@ -704,7 +711,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1formatDictCounts
|
|||
( JNIEnv* env, jclass C, jint gamePtr, jint nCols )
|
||||
{
|
||||
jstring result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_formatDictCounts( state->game.server, stream, nCols );
|
||||
result = streamToJString( MPPARM(mpool) env, stream );
|
||||
|
@ -730,7 +737,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_model_1writeGameHistory
|
|||
( JNIEnv* env, jclass C, jint gamePtr, jboolean gameOver )
|
||||
{
|
||||
jstring result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
model_writeGameHistory( state->game.model, stream, state->game.server,
|
||||
gameOver );
|
||||
|
@ -746,7 +753,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1writeFinalScores
|
|||
( JNIEnv* env, jclass C, jint gamePtr )
|
||||
{
|
||||
jstring result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
server_writeFinalScores( state->game.server, stream );
|
||||
result = streamToJString( MPPARM(mpool) env, stream );
|
||||
|
@ -771,7 +778,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1initClientConnection
|
|||
( JNIEnv* env, jclass C, jint gamePtr )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals );
|
||||
stream_setOnCloseProc( stream, and_send_on_close );
|
||||
server_initClientConnection( state->game.server, stream );
|
||||
|
@ -813,7 +820,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_comms_1setAddr
|
|||
getJAddrRec( env, &addr, jaddr );
|
||||
comms_setAddr( state->game.comms, &addr );
|
||||
} else {
|
||||
XP_LOGF( "%s: no comms this game" );
|
||||
XP_LOGF( "%s: no comms this game", __func__ );
|
||||
}
|
||||
XWJNI_END();
|
||||
}
|
||||
|
@ -823,7 +830,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_game_1receiveMessage
|
|||
( JNIEnv* env, jclass C, jint gamePtr, jbyteArray jstream )
|
||||
{
|
||||
jboolean result;
|
||||
XWJNI_START();
|
||||
XWJNI_START_GLOBALS();
|
||||
XP_ASSERT( state->game.comms );
|
||||
XP_ASSERT( state->game.server );
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ void mpool_destroy( MemPoolCtx* mpool );
|
|||
|
||||
void* mpool_alloc( MemPoolCtx* mpool, XP_U32 size,
|
||||
const char* file, const char* func, XP_U32 lineNo );
|
||||
void* mpool_calloc( MemPoolCtx* mpool, XP_U32 size, const char* file,
|
||||
const char* func, XP_U32 lineNo );
|
||||
void* mpool_realloc( MemPoolCtx* mpool, void* ptr, XP_U32 newsize,
|
||||
const char* file, const char* func, XP_U32 lineNo );
|
||||
void mpool_free( MemPoolCtx* mpool, void* ptr, const char* file,
|
||||
|
|
Loading…
Reference in a new issue