Skip to content

Commit

Permalink
Coverity fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 12, 2015
1 parent 7a0d041 commit 5e1b5a4
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
7 changes: 7 additions & 0 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/core/gps/qextserialport/posix_qextserialport.cpp
Expand Up @@ -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);
Expand Down
8 changes: 7 additions & 1 deletion src/plugins/grass/qgsgrassnewmapset.cpp
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/grass/qtermwidget/Pty.cpp
Expand Up @@ -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()
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/grass/qtermwidget/k3process.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/grass/qtermwidget/k3processcontroller.cpp
Expand Up @@ -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 );
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/grass/qtermwidget/kpty.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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 );
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/providers/grass/qgsgrass.cpp
Expand Up @@ -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;

Expand Down

4 comments on commit 5e1b5a4

@strk
Copy link
Contributor

@strk strk commented on 5e1b5a4 Feb 12, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

@strk strk commented on 5e1b5a4 Feb 12, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef-n
Copy link
Member

@jef-n jef-n commented on 5e1b5a4 Feb 12, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyalldawson thanks for the fixes

Please sign in to comment.