From: Paul Menzel Subject: Warnings in `sna_damage.c` (was: [PATCH] sna: Initialize variable 'iter' to silence clang) Date: Thu, 28 Feb 2013 12:40:41 +0100 Message-ID: <1362051641.9256.51.camel@mattotaupa> References: <1361888117-19708-1-git-send-email-sedat.dilek@gmail.com> <1362041137.9256.27.camel@mattotaupa> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0977516419==" Return-path: Received: from mail.gw90.de (mail.gw90.de [188.40.100.199]) by gabe.freedesktop.org (Postfix) with ESMTP id C7D92E5FA5 for ; Thu, 28 Feb 2013 03:40:44 -0800 (PST) In-Reply-To: <1362041137.9256.27.camel@mattotaupa> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Sedat Dilek Cc: intel-gfx List-Id: intel-gfx@lists.freedesktop.org --===============0977516419== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-i0dJpdKNsJjZpF/7F0a4" --=-i0dJpdKNsJjZpF/7F0a4 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Sedat, Am Donnerstag, den 28.02.2013, 09:45 +0100 schrieb Paul Menzel: > thank you for testing stuff with Clang! >=20 >=20 > Am Dienstag, den 26.02.2013, 15:15 +0100 schrieb Sedat Dilek: >=20 > Please always paste the error/warning messages so reviewers see exactly > what it has find. >=20 > > Signed-off-by: Sedat Dilek > > --- > > src/sna/sna_damage.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > >=20 > > diff --git a/src/sna/sna_damage.c b/src/sna/sna_damage.c > > index ab693af..53ed635 100644 > > --- a/src/sna/sna_damage.c > > +++ b/src/sna/sna_damage.c > > @@ -410,7 +410,7 @@ static void __sna_damage_reduce(struct sna_damage *= damage) > > int n, nboxes; > > BoxPtr boxes, free_boxes =3D NULL; > > pixman_region16_t *region =3D &damage->region; > > - struct sna_damage_box *iter; > > + struct sna_damage_box *iter =3D NULL; >=20 > Looking at the macro in `src/intel_list.h` >=20 > /** > * Loop through the list given by head and set pos to struct in t= he list. > * > * Example: > * struct foo *iterator; > * list_for_each_entry(iterator, &bar->list_of_foos, entry) { > * [modify iterator] > * } > * > * This macro is not safe for node deletion. Use list_for_each_en= try_safe > * instead. > * > * @param pos Iterator variable of the type of the list elements. > * @param head List head > * @param member Member name of the struct list in the list eleme= nts. > * > */ > #define list_for_each_entry(pos, head, member) \ > for (pos =3D __container_of((head)->next, pos, member); \ > &pos->member !=3D (head); \ > pos =3D __container_of(pos->member.next, pos, member)) >=20 > the iterator is definitely initialized in the for loop. >=20 > pos =3D __container_of((head)->next >=20 > > assert(damage->mode !=3D DAMAGE_ALL); > > assert(damage->dirty); > > @@ -1671,7 +1671,7 @@ void _sna_damage_debug_get_region(struct sna_dama= ge *damage, RegionRec *r) > > { > > int n, nboxes; > > BoxPtr boxes; > > - struct sna_damage_box *iter; > > + struct sna_damage_box *iter =3D NULL; > > =20 > > RegionCopy(r, &damage->region); > > if (!damage->dirty) >=20 > So in my opinion this patch should not be applied as it would prevent > the compiler to warn next time when there is really a code change where > this variable might be uninitialized. >=20 > By the way, does `gcc` warn about this? Using GCC I only see the following warnings in `sna_damage.c`. $ gcc -v Using built-in specs. COLLECT_GCC=3D/usr/bin/gcc-4.7.real COLLECT_LTO_WRAPPER=3D/usr/lib/gcc/i486-linux-gnu/4.7/lto-wrapper Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion=3D'Debian 4.= 7.2-15' --with-bugurl=3Dfile:///usr/share/doc/gcc-4.7/README.Bugs --enable-= languages=3Dc,c++,go,fortran,objc,obj-c++ --prefix=3D/usr --program-suffix= =3D-4.7 --enable-shared --enable-linker-build-id --with-system-zlib --libex= ecdir=3D/usr/lib --without-included-gettext --enable-threads=3Dposix --with= -gxx-include-dir=3D/usr/include/c++/4.7 --libdir=3D/usr/lib --enable-nls --= with-sysroot=3D/ --enable-clocale=3Dgnu --enable-libstdcxx-debug --enable-l= ibstdcxx-time=3Dyes --enable-gnu-unique-object --enable-plugin --enable-obj= c-gc --enable-targets=3Dall --enable-multiarch --with-arch-32=3Di586 --with= -multilib-list=3Dm32,m64,mx32 --with-tune=3Dgeneric --enable-checking=3Drel= ease --build=3Di486-linux-gnu --host=3Di486-linux-gnu --target=3Di486-linux= -gnu Thread model: posix gcc version 4.7.2 (Debian 4.7.2-15) $ ./autogen.sh # I=E2=80=99d prefer it did not run ./configure $ make [=E2=80=A6] sna_damage.c: In function '__sna_damage_add_box': sna_damage.c:601:11: warning: cast discards '__attribute__((const))= ' qualifier from pointer target type [-Wcast-qual] sna_damage.c: In function '__sna_damage_contains_box': sna_damage.c:1292:58: warning: cast discards '__attribute__((const)= )' qualifier from pointer target type [-Wcast-qual] sna_damage.c:1305:59: warning: cast discards '__attribute__((const)= )' qualifier from pointer target type [-Wcast-qual] sna_damage.c: In function '_sna_damage_contains_box__no_reduce': sna_damage.c:1346:42: warning: cast discards '__attribute__((const)= )' qualifier from pointer target type [-Wcast-qual] sna_damage.c:1347:7: warning: cast discards '__attribute__((const))= ' qualifier from pointer target type [-Wcast-qual] [=E2=80=A6] Thanks, Paul --=-i0dJpdKNsJjZpF/7F0a4 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEABECAAYFAlEvQjkACgkQPX1aK2wOHViKYACeIiYz0BOq6BFp5UKfABq4IcMv r+0AnRrm0kby0wRG6r32c8ePfyMAb5zz =AS0Q -----END PGP SIGNATURE----- --=-i0dJpdKNsJjZpF/7F0a4-- --===============0977516419== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============0977516419==--