From bd923f154d6aae591c227a16a4d031b0f21a615e Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 26 Jun 2009 10:51:04 +0000 Subject: [PATCH] 2009-06-25 12:47 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbct/ascpos.c * contrib/hbct/ctwfunc.c * contrib/hbct/ctcrypt.c * contrib/xhb/filestat.c * contrib/hbsqlit3/hbsqlit3.c * contrib/hbnf/fttext.c * contrib/hbpgsql/postgres.c * contrib/hbfimage/fi_wrp.c * contrib/hbgd/gdwrp.c * source/rtl/mouse53.c * 'const' cleanup. ; NOTE: I rather didn't commit BYTE to char in CTWIN. ; TOFIX: Some of these will result in warnings when passing values to external API calls. I'd like to ask developers to review what the intent was. Sometimes external API declarations are missing 'const', so it's safe to pass them these buffers, but it should be checked in documentation. --- ../../fi_wrp.c: In function 'HB_FUN_FI_LOADFROMMEM': ../../fi_wrp.c:372: warning: passing argument 1 of 'FreeImage_OpenMemory' discards qualifiers from pointer target type C:\devl\FreeImage-3.12.0\Dist/FreeImage.h:771: note: expected 'BYTE *' but argument is of type 'const BYTE *' ../../fi_wrp.c: In function 'HB_FUN_FI_GETFILETYPEFROMMEM': ../../fi_wrp.c:887: warning: passing argument 1 of 'FreeImage_OpenMemory' discards qualifiers from pointer target type C:\devl\FreeImage-3.12.0\Dist/FreeImage.h:771: note: expected 'BYTE *' but argument is of type 'const BYTE *' ../../gdwrp.c: In function 'HB_FUN_GDIMAGESTRINGFTEX': ../../gdwrp.c:2718: warning: passing argument 4 of 'gdImageStringFTEx' discards qualifiers from pointer target type C:\devl\gd-2.0.34\include/gd.h:459: note: expected 'char *' but argument is of type 'const char *' ../../gdwrp.c:2718: warning: passing argument 9 of 'gdImageStringFTEx' discards qualifiers from pointer target type C:\devl\gd-2.0.34\include/gd.h:459: note: expected 'char *' but argument is of type 'const char *' ../../gdwrp.c: In function 'HB_FUN_GDIMAGESTRINGFTCIRCLE': ../../gdwrp.c:2809: warning: passing argument 7 of 'gdImageStringFTCircle' discards qualifiers from pointer target type C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' ../../gdwrp.c:2809: warning: passing argument 9 of 'gdImageStringFTCircle' discards qualifiers from pointer target type C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' ../../gdwrp.c:2809: warning: passing argument 10 of 'gdImageStringFTCircle' discards qualifiers from pointer target type C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' --- --- harbour/ChangeLog | 40 +++++++++++++++++++++++++++++ harbour/contrib/hbct/ascpos.c | 2 +- harbour/contrib/hbct/ctcrypt.c | 4 +-- harbour/contrib/hbct/ctwfunc.c | 7 ++--- harbour/contrib/hbfimage/fi_wrp.c | 8 +++--- harbour/contrib/hbgd/gdwrp.c | 8 +++--- harbour/contrib/hbnf/fttext.c | 16 ++++++------ harbour/contrib/hbpgsql/postgres.c | 6 ++--- harbour/contrib/hbsqlit3/hbsqlit3.c | 18 ++++++------- harbour/contrib/xhb/filestat.c | 7 ++--- harbour/source/rtl/mouse53.c | 2 +- 11 files changed, 79 insertions(+), 39 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index fe17664016..3f0ec3ca0c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,46 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-25 12:47 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbct/ascpos.c + * contrib/hbct/ctwfunc.c + * contrib/hbct/ctcrypt.c + * contrib/xhb/filestat.c + * contrib/hbsqlit3/hbsqlit3.c + * contrib/hbnf/fttext.c + * contrib/hbpgsql/postgres.c + * contrib/hbfimage/fi_wrp.c + * contrib/hbgd/gdwrp.c + * source/rtl/mouse53.c + * 'const' cleanup. + ; NOTE: I rather didn't commit BYTE to char in CTWIN. + ; TOFIX: Some of these will result in warnings when passing values + to external API calls. I'd like to ask developers to review + what the intent was. Sometimes external API declarations + are missing 'const', so it's safe to pass them these buffers, + but it should be checked in documentation. + --- + ../../fi_wrp.c: In function 'HB_FUN_FI_LOADFROMMEM': + ../../fi_wrp.c:372: warning: passing argument 1 of 'FreeImage_OpenMemory' discards qualifiers from pointer target type + C:\devl\FreeImage-3.12.0\Dist/FreeImage.h:771: note: expected 'BYTE *' but argument is of type 'const BYTE *' + ../../fi_wrp.c: In function 'HB_FUN_FI_GETFILETYPEFROMMEM': + ../../fi_wrp.c:887: warning: passing argument 1 of 'FreeImage_OpenMemory' discards qualifiers from pointer target type + C:\devl\FreeImage-3.12.0\Dist/FreeImage.h:771: note: expected 'BYTE *' but argument is of type 'const BYTE *' + + ../../gdwrp.c: In function 'HB_FUN_GDIMAGESTRINGFTEX': + ../../gdwrp.c:2718: warning: passing argument 4 of 'gdImageStringFTEx' discards qualifiers from pointer target type + C:\devl\gd-2.0.34\include/gd.h:459: note: expected 'char *' but argument is of type 'const char *' + ../../gdwrp.c:2718: warning: passing argument 9 of 'gdImageStringFTEx' discards qualifiers from pointer target type + C:\devl\gd-2.0.34\include/gd.h:459: note: expected 'char *' but argument is of type 'const char *' + ../../gdwrp.c: In function 'HB_FUN_GDIMAGESTRINGFTCIRCLE': + ../../gdwrp.c:2809: warning: passing argument 7 of 'gdImageStringFTCircle' discards qualifiers from pointer target type + C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' + ../../gdwrp.c:2809: warning: passing argument 9 of 'gdImageStringFTCircle' discards qualifiers from pointer target type + C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' + ../../gdwrp.c:2809: warning: passing argument 10 of 'gdImageStringFTCircle' discards qualifiers from pointer target type + C:\devl\gd-2.0.34\include/gdfx.h:41: note: expected 'char *' but argument is of type 'const char *' + --- + 2009-06-26 12:27 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/Makefile * harbour/contrib/hbbmcdx/bmdbfcdx.c diff --git a/harbour/contrib/hbct/ascpos.c b/harbour/contrib/hbct/ascpos.c index 12f2de90b1..dda885b15f 100644 --- a/harbour/contrib/hbct/ascpos.c +++ b/harbour/contrib/hbct/ascpos.c @@ -68,7 +68,7 @@ static void do_ascpos( int iSwitch ) if( HB_ISCHAR( 1 ) ) { size_t sStrSize = hb_parclen( 1 ); - BYTE *pcString = ( BYTE * ) hb_parc( 1 ); + const BYTE *pcString = ( const BYTE * ) hb_parc( 1 ); size_t sPos; if( HB_ISNUM( 2 ) ) diff --git a/harbour/contrib/hbct/ctcrypt.c b/harbour/contrib/hbct/ctcrypt.c index 542b6d2c48..6cec2f32a4 100644 --- a/harbour/contrib/hbct/ctcrypt.c +++ b/harbour/contrib/hbct/ctcrypt.c @@ -58,10 +58,10 @@ HB_FUNC( CRYPT ) if( ulCryptLen >= 2 ) { - BYTE *pbyCrypt = ( BYTE * ) hb_parc( 2 ); + const BYTE *pbyCrypt = ( const BYTE * ) hb_parc( 2 ); ULONG ulCryptPos = 0; - BYTE *pbyString = ( BYTE * ) hb_parc( 1 ); + const BYTE *pbyString = ( const BYTE * ) hb_parc( 1 ); ULONG ulStringLen = hb_parclen( 1 ); ULONG ulStringPos; diff --git a/harbour/contrib/hbct/ctwfunc.c b/harbour/contrib/hbct/ctwfunc.c index 1e60532e40..9d89fd6d3f 100644 --- a/harbour/contrib/hbct/ctwfunc.c +++ b/harbour/contrib/hbct/ctwfunc.c @@ -207,12 +207,13 @@ HB_FUNC( WBOX ) "олнннлоо", /* 14 WB_FULL_HALF */ "лллллллл" }; /* 15 WB_FULL */ - BYTE * szBox, szBoxBuf[ 10 ]; + const BYTE * szBox; + BYTE szBoxBuf[ 10 ]; int iColor; if( HB_ISCHAR( 1 ) ) { - szBox = ( BYTE * ) hb_parc( 1 ); + szBox = ( const BYTE * ) hb_parc( 1 ); } else { @@ -336,7 +337,7 @@ HB_FUNC( CTWLASTKEY ) hb_retni( hb_ctwLastKey() ); } -/* NOTE: These two functions are emulating the MaxRow()/MaxCol() core functions +/* NOTE: These two functions are emulating the MaxRow()/MaxCol() core functions "overloaded" by the CT3 library. */ HB_FUNC( HBCT_MAXROW ) /* Return the maximum screen/window row number (zero origin) */ diff --git a/harbour/contrib/hbfimage/fi_wrp.c b/harbour/contrib/hbfimage/fi_wrp.c index 79968e3fc2..aa57f7bb59 100644 --- a/harbour/contrib/hbfimage/fi_wrp.c +++ b/harbour/contrib/hbfimage/fi_wrp.c @@ -360,12 +360,12 @@ HB_FUNC( FI_LOADFROMMEM ) FIBITMAP *dib; FREE_IMAGE_FORMAT fif; FIMEMORY *stream; - BYTE *szImage; + const BYTE *szImage; int flags; /* Retrieve parameters */ fif = (FREE_IMAGE_FORMAT) hb_parni( 1 ); - szImage = ( BYTE * ) hb_parcx( 2 ); + szImage = ( const BYTE * ) hb_parcx( 2 ); flags = hb_parni( 3 ); /* run function */ @@ -878,12 +878,12 @@ HB_FUNC( FI_GETFILETYPEFROMMEM ) hb_parinfo( 1 ) & HB_IT_STRING ) { - BYTE * szImage; + const BYTE * szImage; FIMEMORY *stream; int size; /* Retrieve parameters */ - szImage = ( BYTE * ) hb_parcx( 1 ); + szImage = ( const BYTE * ) hb_parcx( 1 ); stream = FreeImage_OpenMemory( szImage, hb_parclen(1) ); size = ( hb_parinfo( 2 ) & HB_IT_NUMERIC ? hb_parni( 1 ) : 0 ); diff --git a/harbour/contrib/hbgd/gdwrp.c b/harbour/contrib/hbgd/gdwrp.c index 71ef9904ce..dc0100c1a7 100644 --- a/harbour/contrib/hbgd/gdwrp.c +++ b/harbour/contrib/hbgd/gdwrp.c @@ -2628,10 +2628,10 @@ HB_FUNC( GDIMAGESTRINGFTEX ) gdImagePtr im; gdFTStringExtra extra; int fg; - char *fontname; + const char *fontname; double ptsize, angle; int x, y, i; - char *string; + const char *string; PHB_ITEM pRect; int aRect[8]; char *err; @@ -2768,10 +2768,10 @@ HB_FUNC( GDIMAGESTRINGFTCIRCLE ) /* char *gdImageStringFTCircle(gdImagePtr im, i gdImagePtr im; int cx, cy; double radius, textRadius, fillPortion, points; - char *top; + const char *top; const char *bottom; int fgcolor; - char *font; + const char *font; char *err; /* Retrieve image pointer */ diff --git a/harbour/contrib/hbnf/fttext.c b/harbour/contrib/hbnf/fttext.c index 76aa5a9314..aeb09840eb 100644 --- a/harbour/contrib/hbnf/fttext.c +++ b/harbour/contrib/hbnf/fttext.c @@ -191,7 +191,7 @@ static int _findbol( BYTE * buf, int buf_len ); static int _ins_buff( int bytes ); static int _del_buff( int bytes ); static long _ft_skip( long recs ); -static int _writeLine( BYTE * theData, ULONG iDataLen ); +static int _writeLine( const BYTE * theData, ULONG iDataLen ); static BOOL _writeeol( HB_FHANDLE fhnd ); /* arrays used by the text workareas */ @@ -1330,7 +1330,7 @@ HB_FUNC( FT_FAPPEND ) HB_FUNC( FT_FWRITEL ) { - BYTE * theData = ( BYTE * ) hb_parc( 1 ); + const BYTE * theData = ( const BYTE * ) hb_parc( 1 ); int iDataLen = hb_parclen( 1 ); int lInsert = ( HB_ISLOG( 2 ) ? hb_parl( 2 ) : 0 ); int err; @@ -1720,16 +1720,16 @@ static int _findbol( BYTE * buf, int buf_len ) { p--; tmp--; - + if( tmp == 0 ) return buf_len; } - + if( b == FT_CHR_LF ) { p--; tmp--; - + if( tmp == 0 ) return buf_len; @@ -1737,12 +1737,12 @@ static int _findbol( BYTE * buf, int buf_len ) { p--; tmp--; - + if( tmp == 0 ) return buf_len; } } - + for( ; tmp > 0; tmp--, p-- ) { if( *p == FT_CHR_LF && *( p - 1 ) == FT_CHR_CR ) @@ -1956,7 +1956,7 @@ static int _del_buff( int iLen ) /*--------------------------------------------------------------------------*/ /* writes a line of data to the file, including the terminating CRLF */ -static int _writeLine( BYTE * theData, ULONG iDataLen ) +static int _writeLine( const BYTE * theData, ULONG iDataLen ) { int err = 0; diff --git a/harbour/contrib/hbpgsql/postgres.c b/harbour/contrib/hbpgsql/postgres.c index 1948defbae..2440e43b27 100644 --- a/harbour/contrib/hbpgsql/postgres.c +++ b/harbour/contrib/hbpgsql/postgres.c @@ -564,11 +564,9 @@ HB_FUNC( PQESCAPESTRING ) HB_FUNC( PQESCAPEBYTEA ) /* deprecated */ { - unsigned const char * from = ( BYTE * ) hb_parc( 1 ); size_t from_length = hb_parclen( 1 ); size_t to_length = from_length * 5 + 1; - - unsigned char * to = PQescapeBytea( from, from_length, &to_length ); + unsigned char * to = PQescapeBytea( ( const unsigned char * ) hb_parcx( 1 ), from_length, &to_length ); hb_retc( ( char * ) to ); /* TOFIX: ? hb_retc( ( char * ) to, to_length ); */ PQfreemem( to ); } @@ -577,7 +575,7 @@ HB_FUNC( PQESCAPEBYTEA ) /* deprecated */ HB_FUNC( PQUNESCAPEBYTEA ) { size_t to_length; - unsigned char * from = PQunescapeBytea( ( BYTE * ) hb_parcx( 1 ), &to_length ); + unsigned char * from = PQunescapeBytea( ( const unsigned char * ) hb_parcx( 1 ), &to_length ); hb_retclen( ( char * ) from, to_length ); PQfreemem( from ); } diff --git a/harbour/contrib/hbsqlit3/hbsqlit3.c b/harbour/contrib/hbsqlit3/hbsqlit3.c index 9fcc25561d..494fc123b2 100644 --- a/harbour/contrib/hbsqlit3/hbsqlit3.c +++ b/harbour/contrib/hbsqlit3/hbsqlit3.c @@ -547,7 +547,7 @@ HB_FUNC( SQLITE3_TEMP_DIRECTORY ) #ifdef SQLITE3_LIB { BOOL fFree; - BYTE *pszDirName = hb_fsNameConv( ( BYTE * ) hb_parcx(1), &fFree ); + BYTE *pszDirName = hb_fsNameConv( hb_parcx(1), &fFree ); if( hb_fsIsDirectory(pszDirName) ) { @@ -956,7 +956,7 @@ HB_FUNC( SQLITE3_BIND_BLOB ) if( pStmt ) { - hb_retni( sqlite3_bind_blob(pStmt, hb_parni(2), ( const char * ) hb_parcx(3), hb_parcsiz(3) - 1, SQLITE_TRANSIENT) ); + hb_retni( sqlite3_bind_blob(pStmt, hb_parni(2), hb_parcx(3), hb_parcsiz(3) - 1, SQLITE_TRANSIENT) ); } else { @@ -1027,7 +1027,7 @@ HB_FUNC( SQLITE3_BIND_TEXT ) if( pStmt ) { - hb_retni( sqlite3_bind_text(pStmt, hb_parni(2), ( const char * ) hb_parc(3), hb_parclen(3), SQLITE_TRANSIENT) ); + hb_retni( sqlite3_bind_text(pStmt, hb_parni(2), hb_parc(3), hb_parclen(3), SQLITE_TRANSIENT) ); } else { @@ -1467,9 +1467,9 @@ HB_FUNC( SQLITE3_TABLE_COLUMN_METADATA ) sqlite3_table_column_metadata ( pHbSqlite3->db, - ( const char * ) hb_parc(2) /* zDbName */, - ( const char * ) hb_parc(3) /* zTableName */, - ( const char * ) hb_parc(4) /* zColumnName */, + hb_parc(2) /* zDbName */, + hb_parc(3) /* zTableName */, + hb_parc(4) /* zColumnName */, &pzDataType /* pzDataDtype */, &pzCollSeq /* pzCollSeq */, &iNotNull, @@ -1572,9 +1572,9 @@ HB_FUNC( SQLITE3_BLOB_OPEN ) sqlite3_blob_open ( pHbSqlite3->db, - ( const char * ) hb_parc(2) /* zDb */, - ( const char * ) hb_parc(3) /* zTable */, - ( const char * ) hb_parc(4) /* zColumn */, + hb_parc(2) /* zDb */, + hb_parc(3) /* zTable */, + hb_parc(4) /* zColumn */, (sqlite3_int64) hb_parnint(5) /* iRow */, hb_parni(6) /* flags */, &ppBlob diff --git a/harbour/contrib/xhb/filestat.c b/harbour/contrib/xhb/filestat.c index f449db6be8..a52a1e913e 100644 --- a/harbour/contrib/xhb/filestat.c +++ b/harbour/contrib/xhb/filestat.c @@ -71,7 +71,7 @@ #endif static BOOL hb_fsFileStats( - BYTE *pszFileName, + const char *pszFileName, BYTE *pszAttr, HB_FOFFSET *llSize, LONG *lcDate, @@ -85,7 +85,7 @@ static BOOL hb_fsFileStats( struct stat statbuf; - if( stat( ( char * ) pszFileName, &statbuf ) == 0 ) + if( stat( pszFileName, &statbuf ) == 0 ) { // determine if we can read/write/execute the file USHORT usAttr, ushbAttr = 0; @@ -265,7 +265,8 @@ static BOOL hb_fsFileStats( HB_FUNC( FILESTATS ) { - BYTE szAttr[21], *szFile = ( BYTE * ) hb_parc( 1 ); + BYTE szAttr[ 21 ]; + const char * szFile = hb_parc( 1 ); HB_FOFFSET lSize = 0; LONG lcDate = 0, lcTime = 0, lmDate = 0, lmTime = 0; diff --git a/harbour/source/rtl/mouse53.c b/harbour/source/rtl/mouse53.c index 887552455f..a39cf6e7f1 100644 --- a/harbour/source/rtl/mouse53.c +++ b/harbour/source/rtl/mouse53.c @@ -154,7 +154,7 @@ HB_FUNC( MRESTSTATE ) { if( HB_ISCHAR( 1 ) && hb_parclen( 1 ) == ( ULONG ) hb_mouseStorageSize() ) { - hb_mouseRestoreState( ( BYTE * ) hb_parc( 1 ) ); + hb_mouseRestoreState( ( const BYTE * ) hb_parc( 1 ) ); } }