From: Paul Menzel Subject: Re: [PATCH] sna: Initialize variable 'iter' to silence clang Date: Thu, 28 Feb 2013 09:45:37 +0100 Message-ID: <1362041137.9256.27.camel@mattotaupa> References: <1361888117-19708-1-git-send-email-sedat.dilek@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1788609323==" Return-path: Received: from mail.gw90.de (mail.gw90.de [188.40.100.199]) by gabe.freedesktop.org (Postfix) with ESMTP id F0A9DE5C28 for ; Thu, 28 Feb 2013 00:45:48 -0800 (PST) In-Reply-To: <1361888117-19708-1-git-send-email-sedat.dilek@gmail.com> 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 --===============1788609323== Content-Type: multipart/signed; micalg="pgp-sha1"; protocol="application/pgp-signature"; boundary="=-hRuG7R9KIbr3qrOzmcYG" --=-hRuG7R9KIbr3qrOzmcYG Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Dear Sedat, thank you for testing stuff with Clang! Am Dienstag, den 26.02.2013, 15:15 +0100 schrieb Sedat Dilek: Please always paste the error/warning messages so reviewers see exactly what it has find. > 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 *da= mage) > 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; Looking at the macro in `src/intel_list.h` /** * Loop through the list given by head and set pos to struct in the= 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_entr= y_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 element= s. * */ #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)) the iterator is definitely initialized in the for loop. pos =3D __container_of((head)->next > assert(damage->mode !=3D DAMAGE_ALL); > assert(damage->dirty); > @@ -1671,7 +1671,7 @@ void _sna_damage_debug_get_region(struct sna_damage= *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) 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. By the way, does `gcc` warn about this? Thanks, Paul --=-hRuG7R9KIbr3qrOzmcYG 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) iEYEABECAAYFAlEvGTEACgkQPX1aK2wOHVhgdACfdLFwEkt0VfMz9AKIqGTdfFf2 58AAmgMRBY8iJBTgV+NMPmec73xSvYKF =R7+D -----END PGP SIGNATURE----- --=-hRuG7R9KIbr3qrOzmcYG-- --===============1788609323== 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 --===============1788609323==--