The warning is easy to silence, the bigger problem
is that this function will modify HVM string directly,
which may cause HVM corruption.

It needs to be rewritten to work on a copy of the
string.

We have the exact same kind of problems waiting to be
fixed in examples/gfspell.

Brgds,
Viktor

On 2009 Sep 28, at 11:30, Lorenzo Fiorini wrote:

This is an old C function but it's used in a 3rd party lib so I can't
use HB's standard one.
When I build it with 2.0.0beta3 gcc warnings. How can I fix it?

#include <extend.h>

#ifdef __HARBOUR__
HB_FUNC( BIT )
#else
CLIPPER bit( void )
#endif
{
  char            *ptr;
  unsigned char   mask;
  unsigned int    loc,
                  offset = _parni( 2 ) - 1,
                  res    = 0;

  loc = offset / 8;
  if ( loc < _parclen( 1 ) )
  {
     ptr = _parc( 1 ) + loc;  <---- warning here
     loc = offset % 8;
     res = *ptr << loc & 0x80;

     if ( PCOUNT > 2 )
     {
        mask = (unsigned char ) 0x80 >> loc;
        if ( _parl( 3 ) )
           *ptr = *ptr | mask;
        else
           *ptr = *ptr & ~mask;
     }
  }
  _retl( res );
}

best regards,
Lorenzo
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to