I don't like this patch. It artificially introduces a pointer just to shut up the compiler.
NAK /D On Sun, Jul 20, 2014 at 03:50:28PM +0300, Lubomir I. Ivanov wrote: > From: "Lubomir I. Ivanov" <[email protected]> > > If you take the address of a extern struct and pass it to > a macro (FOR_EACH_PICTURE) where there is a check if this > address is not NULL you will get a -Waddress warning. > > The address of such a variable cannot ever be NULL. > > To solve that we create a function local pointer and pass > it to the macro itself. > > On a wider scale (i.e. the macro is used with a lot of different > extern variables) the better solution is to define another > macro FOR_EACH_PICTURE_SAFE where only the NULL check exists. > > Signed-off-by: Lubomir I. Ivanov <[email protected]> > --- > qt-ui/divepicturewidget.cpp | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp > index fd64f61..8e2f097 100644 > --- a/qt-ui/divepicturewidget.cpp > +++ b/qt-ui/divepicturewidget.cpp > @@ -34,20 +34,21 @@ SPixmap scaleImages(const QString &s) > > void DivePictureModel::updateDivePictures() > { > + struct dive *displayed = &displayed_dive; > if (numberOfPictures != 0) { > beginRemoveRows(QModelIndex(), 0, numberOfPictures - 1); > numberOfPictures = 0; > endRemoveRows(); > } > > - numberOfPictures = dive_get_picture_count(&displayed_dive); > + numberOfPictures = dive_get_picture_count(displayed); > if (numberOfPictures == 0) { > return; > } > > stringPixmapCache.clear(); > QStringList pictures; > - FOR_EACH_PICTURE (&displayed_dive) { > + FOR_EACH_PICTURE (displayed) { > stringPixmapCache[QString(picture->filename)].picture = picture; > pictures.push_back(QString(picture->filename)); > } > -- > 1.7.11.msysgit.0 > > _______________________________________________ > subsurface mailing list > [email protected] > http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
