From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1VmhxW-000841-8C for mharc-grub-devel@gnu.org; Sat, 30 Nov 2013 05:39:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmhxL-00083S-JH for grub-devel@gnu.org; Sat, 30 Nov 2013 05:39:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VmhxD-0005zi-6c for grub-devel@gnu.org; Sat, 30 Nov 2013 05:39:23 -0500 Received: from mail-ea0-x233.google.com ([2a00:1450:4013:c01::233]:51077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VmhxC-0005ze-V8 for grub-devel@gnu.org; Sat, 30 Nov 2013 05:39:15 -0500 Received: by mail-ea0-f179.google.com with SMTP id r15so7565657ead.10 for ; Sat, 30 Nov 2013 02:39:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=LgAk0bazEEbiAnWL/f5VKLDtfncYtHrZepZHir8K6Eo=; b=PfcGsC3oPf9URWS3pTmdK6Wv3mKQIjz4787UmekECEqHlume+puhNNSNli2p/e4FVz Shv+vaWatE1SR0eFKaLyQm0IaGD91ck8bOf+2nelUArS82iU2Q3Tb3Rv/3481MhcGD+H SsV06PF47sLynJc/ubqIc3+x+yHAiv09qbS/D1TWZBJMPV8n3Ii04XE21Zovww01gGs7 KlVC2oAGzO2Y4/UTqzAoDlX+iccNlEXLUlxgu20DTUffDu2lRJd2+ER7hxSAb4JXEIT7 UWa9cPqIaH+82Uy81VVxzmcwK8++Sfb3ba9CKpL+Y5mRl7sJ3K8uixVXCmWS/Sst8t9n RIUg== X-Received: by 10.15.32.73 with SMTP id z49mr57168665eeu.27.1385807954096; Sat, 30 Nov 2013 02:39:14 -0800 (PST) Received: from [192.168.1.16] (31-249.1-85.cust.bluewin.ch. [85.1.249.31]) by mx.google.com with ESMTPSA id a51sm49688419eeh.8.2013.11.30.02.39.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 30 Nov 2013 02:39:13 -0800 (PST) Message-ID: <5299C050.4040507@gmail.com> Date: Sat, 30 Nov 2013 11:39:12 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131005 Icedove/17.0.9 MIME-Version: 1.0 To: The development of GNU GRUB Subject: Re: [PATCH] add grub_qsort_strcmp to use when sorting array of strings References: <1385744460-6624-1-git-send-email-arvidjaar@gmail.com> In-Reply-To: <1385744460-6624-1-git-send-email-arvidjaar@gmail.com> X-Enigmail-Version: 1.5.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="----enig2USUFQWGJJBWMHFIVPKVW" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::233 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 30 Nov 2013 10:39:32 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2USUFQWGJJBWMHFIVPKVW Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 29.11.2013 18:01, Andrey Borzenkov wrote: > Compare function used in qsort gets arguments by reference, so strcmp > cannot be used directly - it expects pointer to char, but gets pointer > to pointer to char. >=20 > Introduce new helper grub_qsort_strcmp and use it in grub-install. > This helper is going to be used in a couple more places as well so > add it to global file, not in grub-install.c. >=20 Nice catch. But I don't we have enough use for grub_qsort_strcmp to make it global. Can you make it static in grub-install.c ? > --- > include/grub/util/misc.h | 2 ++ > util/grub-install.c | 2 +- > util/misc.c | 8 ++++++++ > 3 files changed, 11 insertions(+), 1 deletion(-) >=20 > diff --git a/include/grub/util/misc.h b/include/grub/util/misc.h > index 6aacf23..192874d 100644 > --- a/include/grub/util/misc.h > +++ b/include/grub/util/misc.h > @@ -47,4 +47,6 @@ void grub_util_init_nls (void); > =20 > void grub_util_host_init (int *argc, char ***argv); > =20 > +int grub_qsort_strcmp (const void *, const void *); > + > #endif /* ! GRUB_UTIL_MISC_HEADER */ > diff --git a/util/grub-install.c b/util/grub-install.c > index 5354a6d..1870182 100644 > --- a/util/grub-install.c > +++ b/util/grub-install.c > @@ -583,7 +583,7 @@ device_map_check_duplicates (const char *dev_map) > =20 > fclose (fp); > =20 > - qsort (d, filled, sizeof (d[0]), (int (*) (const void *, const void = *))strcmp); > + qsort (d, filled, sizeof (d[0]), grub_qsort_strcmp); > =20 > for (i =3D 0; i + 1 < filled; i++) > if (strcmp (d[i], d[i+1]) =3D=3D 0) > diff --git a/util/misc.c b/util/misc.c > index 0de340b..9eb1fc1 100644 > --- a/util/misc.c > +++ b/util/misc.c > @@ -256,3 +256,11 @@ void > grub_register_exported_symbols (void) > { > } > + > +/* Used in comparison of arrays of strings with qsort */ > +int > +grub_qsort_strcmp (const void *p1, const void *p2) > +{ > + return strcmp(*(char **)p1, *(char **)p2); > +} > + >=20 ------enig2USUFQWGJJBWMHFIVPKVW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.15 (GNU/Linux) Comment: Using GnuPG with Icedove - http://www.enigmail.net/ iF4EAREKAAYFAlKZwFAACgkQmBXlbbo5nOv0UQD/QxIfcfEz4e6n3CQ1c55rmcYB 0UtmCJ9lYpeRlEgbZU4A/ixBHBs2wCGd9z+Ar4ZXg7W5U4ZIY9QPXN0cpehq/eUg =TQ7J -----END PGP SIGNATURE----- ------enig2USUFQWGJJBWMHFIVPKVW--