Skip to content
Permalink
Browse files

Coverity fixes

  • Loading branch information
nyalldawson committed Feb 12, 2015
1 parent 7a0d041 commit 5e1b5a43f27a62ef785d958d4d9ee898e2a95f7e
@@ -74,7 +74,14 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
: QgsOptionsDialogBase( "VectorLayerProperties", parent, fl )
, layer( lyr )
, mMetadataFilled( false )
, mSaveAsMenu( 0 )
, mLoadStyleMenu( 0 )
, mRendererDialog( 0 )
, labelingDialog( 0 )
, labelDialog( 0 )
, actionDialog( 0 )
, diagramPropertiesDialog( 0 )
, mFieldsPropertiesDialog( 0 )
{
setupUi( this );
// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
@@ -663,11 +663,11 @@ void QextSerialPort::setTimeout(long millisec)
Posix_Copy_Timeout.tv_usec = millisec % 1000;
if (isOpen()) {
if (millisec == -1)
fcntl(fd, F_SETFL, O_NDELAY);
(void)fcntl(fd, F_SETFL, O_NDELAY);
else
//O_SYNC should enable blocking ::write()
//however this seems not working on Linux 2.6.21 (works on OpenBSD 4.2)
fcntl(fd, F_SETFL, O_SYNC);
(void)fcntl(fd, F_SETFL, O_SYNC);
tcgetattr(fd, & Posix_CommConfig);
Posix_CommConfig.c_cc[VTIME] = millisec/100;
tcsetattr(fd, TCSAFLUSH, & Posix_CommConfig);
@@ -1263,7 +1263,13 @@ void QgsGrassNewMapset::createMapset()

// TODO: add QgsGrass::setLocation or G_make_location with
// database path
QgsGrass::activeMode(); // because it calls private QgsGrass::init()
if ( !QgsGrass::activeMode() ) // because it calls private QgsGrass::init()

This comment has been minimized.

Copy link
@blazek

blazek Apr 8, 2015

Member

This is not correct fix, GRASS does not have to be in active mode to create a new mapset. This breaks create new mapset wizard. I am going to revert this in master and 2.8 branch, then I'll fix coverity warning in master .

{
QMessageBox::warning( this, tr( "Create mapset" ),
tr( "Cannot activate grass" ) );
return;
}

#if defined(WIN32)
G__setenv(( char * ) "GISDBASE", QgsGrass::shortPath( mDatabaseLineEdit->text() ).toUtf8().data() );
#else
@@ -226,9 +226,9 @@ void Pty::setWriteable( bool writeable )
struct stat sbuf;
stat( pty()->ttyName(), &sbuf );
if ( writeable )
chmod( pty()->ttyName(), sbuf.st_mode | S_IWGRP );
(void)chmod( pty()->ttyName(), sbuf.st_mode | S_IWGRP );
else
chmod( pty()->ttyName(), sbuf.st_mode & ~( S_IWGRP | S_IWOTH ) );
(void)chmod( pty()->ttyName(), sbuf.st_mode & ~( S_IWGRP | S_IWOTH ) );
}

Pty::Pty()
@@ -317,7 +317,7 @@ bool K3Process::start( RunMode runmode, Communication comm )

close( fd[0] );
// Closing of fd[1] indicates that the execvp() succeeded!
fcntl( fd[1], F_SETFD, FD_CLOEXEC );
(void)fcntl( fd[1], F_SETFD, FD_CLOEXEC );

if ( !commSetupDoneC() )
qDebug() << "Could not finish comm setup in child!" << endl;
@@ -874,15 +874,15 @@ int K3Process::setupCommunication( Communication comm )
{
if ( socketpair( AF_UNIX, SOCK_STREAM, 0, out ) )
goto fail1;
fcntl( out[0], F_SETFD, FD_CLOEXEC );
fcntl( out[1], F_SETFD, FD_CLOEXEC );
(void)fcntl( out[0], F_SETFD, FD_CLOEXEC );
(void)fcntl( out[1], F_SETFD, FD_CLOEXEC );
}
if ( comm & Stderr )
{
if ( socketpair( AF_UNIX, SOCK_STREAM, 0, err ) )
goto fail2;
fcntl( err[0], F_SETFD, FD_CLOEXEC );
fcntl( err[1], F_SETFD, FD_CLOEXEC );
(void)fcntl( err[0], F_SETFD, FD_CLOEXEC );
(void)fcntl( err[1], F_SETFD, FD_CLOEXEC );
}
return 1; // Ok
fail2:
@@ -923,7 +923,7 @@ int K3Process::commSetupDoneP()

if ( communication & Stdin )
{
fcntl( in[1], F_SETFL, O_NONBLOCK | fcntl( in[1], F_GETFL ) );
(void)fcntl( in[1], F_SETFL, O_NONBLOCK | fcntl( in[1], F_GETFL ) );
innot = new QSocketNotifier( in[1], QSocketNotifier::Write, this );
Q_CHECK_PTR( innot );
innot->setEnabled( false ); // will be enabled when data has to be sent
@@ -105,10 +105,10 @@ K3ProcessController::K3ProcessController()
abort();
}

fcntl( d->fd[0], F_SETFL, O_NONBLOCK ); // in case slotDoHousekeeping is called without polling first
fcntl( d->fd[1], F_SETFL, O_NONBLOCK ); // in case it fills up
fcntl( d->fd[0], F_SETFD, FD_CLOEXEC );
fcntl( d->fd[1], F_SETFD, FD_CLOEXEC );
(void)fcntl( d->fd[0], F_SETFL, O_NONBLOCK ); // in case slotDoHousekeeping is called without polling first
(void)fcntl( d->fd[1], F_SETFL, O_NONBLOCK ); // in case it fills up
(void)fcntl( d->fd[0], F_SETFD, FD_CLOEXEC );
(void)fcntl( d->fd[1], F_SETFD, FD_CLOEXEC );

d->notifier = new QSocketNotifier( d->fd[0], QSocketNotifier::Read );
d->notifier->setEnabled( true );
@@ -370,8 +370,8 @@ bool KPty::open()

//#endif /* HAVE_OPENPTY */

fcntl( d->masterFd, F_SETFD, FD_CLOEXEC );
fcntl( d->slaveFd, F_SETFD, FD_CLOEXEC );
(void)fcntl( d->masterFd, F_SETFD, FD_CLOEXEC );
(void)fcntl( d->slaveFd, F_SETFD, FD_CLOEXEC );

return true;
}
@@ -403,12 +403,12 @@ void KPty::close()
{
if( chown( d->ttyName.data(), 0, st.st_gid == getgid() ? 0 : -1 ) < 0 )
perror( "chown" );
chmod( d->ttyName.data(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
(void)chmod( d->ttyName.data(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH );
}
}
else
{
fcntl( d->masterFd, F_SETFD, 0 );
(void)fcntl( d->masterFd, F_SETFD, 0 );
d->chownpty( false );
}
}
@@ -1208,7 +1208,12 @@ bool GRASS_LIB_EXPORT QgsGrass::mapRegion( int type, QString gisbase,
else if ( type == Vector )
{
// Get current projection
region( gisbase, location, mapset, window );
if ( !region( gisbase, location, mapset, window ) )
{
QMessageBox::warning( 0, QObject::tr( "Warning" ),
QObject::tr( "Cannot read vector map region" ) );
return false;
}

struct Map_info Map;

4 comments on commit 5e1b5a4

@strk

This comment has been minimized.

Copy link
Contributor

@strk strk replied Feb 12, 2015

It would be nice if the commit log said something more explicit about what the commit does. Like "initialize all members", "handle errors from grass region reading" etc...

@nyalldawson

This comment has been minimized.

Copy link
Collaborator Author

@nyalldawson nyalldawson replied Feb 12, 2015

@strk - it's just a mix. nothing really important here, I'm just clearing off some trivial Coverity issues to increase the signal to noise ratio

@strk

This comment has been minimized.

Copy link
Contributor

@strk strk replied Feb 12, 2015

@jef-n

This comment has been minimized.

Copy link
Member

@jef-n jef-n replied Feb 12, 2015

@nyalldawson thanks for the fixes

Please sign in to comment.
You can’t perform that action at this time.