From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 14086 invoked from network); 26 May 2023 14:07:13 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 26 May 2023 14:07:13 -0000 Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 0862d690; Fri, 26 May 2023 14:06:56 +0000 (UTC) Return-Path: Received: from mx.mylinuxtime.de (mx.mylinuxtime.de [2a01:4f8:13a:16c2::25]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id 97733acb (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 26 May 2023 14:06:55 +0000 (UTC) Received: from leda.eworm.net (unknown [185.209.196.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx.mylinuxtime.de (Postfix) with ESMTPSA id 7475122980C; Fri, 26 May 2023 16:06:54 +0200 (CEST) Date: Fri, 26 May 2023 16:06:53 +0200 From: Christian Hesse To: "Jason A. Donenfeld" Cc: cgit@lists.zx2c4.com, Christian Hesse Subject: Re: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 Message-ID: <20230526160653.7962c827@leda.eworm.net> In-Reply-To: References: <20230526110646.60621-1-list@eworm.de> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) X-Face: %O:rCSkHSKf7^4uF|FD$9$I0}g$nbnS1{DYPvs#:,~e`).mzj\$P9]V!WCveE/XdbL,L!{)6v%x4\Bt!b#{; dS&h"7l=ow'^({02!2%XOugod|u*mYBVm-OS:VpZ"ZrRA4[Q&zye,^j; ftj!Hxx\1@; LM)Pz)|B%1#sfF; s; ,N?*K*^) Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUZFRFENy6KVTKEd23CiGHeqofJvrX4+vdHgItOAAAACXBIWXMAAA3XAAAN1wFCKJt4AAACUklEQVQ4y2VUTZeqMAxNxXG2Io5uGd64L35unbF9ax0b3OLxgFs4PcLff0lBHeb1QIq5uelNCEJNq/TIFGyeC+iugH0WJr+B1MvzWASpuP4CYHOB0VfoDdddwA7OIFQIEHjXDiCtV5e9QX0WMu8AG0mB7g7WP4GqeqVdsi4vv/5kFBvaF/zD7zDquL4DxbrDGDyAsgNYOsJOYzth4Q9ZF6iLV+6TLAT1pi2kuvgAtZxSjoG8cL+8vIn251uoe1OOEWwbIPU04gHsmMsoxyyhYsD2FdIigF1yxaVbBuSOCAlCoX324I7wNMhrO1bhOLsRoA6DC6wQ5eQiSG5BiWQfM4gN+uItQTRDMaJUhVbGyKWCuaaUGSVFVKpl4PdoDn3yY8J+YxQxyhlHfoYOyPgyDcO+cSQK6Bvabjcy2nwRo3pxgA8jslnCuYw23ESOzHAPYwo4ITNQMaOO+RGPEGhSlPEZBh2jmBEjQ5cKbxmr0ruAe/WCriUxW76I8T3h7vqY5VR5wXLdERodg2rHEzdxxk5KpXTL4FwnarvndKM5/MWDY5CuBBdQ+3/0ivsUJHicuHd+Xh3jOdBL+FjSGq4SPCwco+orpWlERRTNo7BHCvbNXFVSIQMp+P5QsIL9upmr8kMTUOfxEHoanwzKRcNAe76WbjBwex/RkdHu48xT5YqP70DaMOhBcTHmAVDxLaBdle93oJy1QKFUh2GXT4am+YH/GGel1CeI98GdMXsytjCKIq/9cMrlgxFCROv+3/BU1fijNpcVD6DxE8VfLBaxUGr1D5usgDYdjwiPAAAAAElFTkSuQmCC MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/i9ervaoLMS_qzfjvgUCWLqI"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-BeenThere: cgit@lists.zx2c4.com X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: List for cgit developers and users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: cgit-bounces@lists.zx2c4.com Sender: "CGit" --Sig_/i9ervaoLMS_qzfjvgUCWLqI Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable "Jason A. Donenfeld" on Fri, 2023/05/26 15:42: > On Fri, May 26, 2023 at 1:07=E2=80=AFPM Christian Hesse w= rote: > > @@ -564,9 +566,11 @@ char *get_mimetype_for_filename(const char *filena= me) > > while (fgets(line, sizeof(line), file)) { > > if (!line[0] || line[0] =3D=3D '#') > > continue; > > - mimetype =3D strtok_r(line, " \t\r\n", &saveptr); > > - while ((token =3D strtok_r(NULL, " \t\r\n", &saveptr)))= { > > - if (!strcasecmp(ext, token)) { > > + string_list_split_in_place(&list, line, " \t\r\n", -1); > > + string_list_remove_empty_items(&list, 0); > > + mimetype =3D list.items[0].string; > > + for (i =3D 1; i < list.nr; i++) { > > + if (!strcasecmp(ext, list.items[i].string)) { > > fclose(file); > > return xstrdup(mimetype); > > } =20 >=20 > What's the motivation here exactly? string_list allocates, I believe, > for its items array even if you set nostrdup, so that code probably > needs a free path. But also, what's the point of doing the splitting > up front and then iterating, rather than just munging the string like > usual with strtok_r? Well, `strtok_r()` is now banned... https://github.com/gitster/git/commit/60ff56f50372c1498718938ef504e744fe011= ffb ... and the commit messages suggests to use `string_list_split_in_place()` instead. In contrast to `string_list_split()` it does not allocate but spli= ts - as the name suggests - in place. From `string-list.h`: > Like string_list_split(), except that string is split in-place: the > delimiter characters in string are overwritten with NULs, and the > new string_list_items point into string (which therefore must not > be modified or freed while the string_list is in use). > list->strdup_strings must *not* be set. So we should be fine with the change, no? --=20 main(a){char*c=3D/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Best regards my address: */=3D0;b=3Dc[a+= +];) putchar(b-1/(/* Chris cc -ox -xc - && ./x */b/42*2-3)*42);} --Sig_/i9ervaoLMS_qzfjvgUCWLqI Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEXHmveYAHrRp+prOviUUh18yA9HYFAmRwvP0ACgkQiUUh18yA 9HaZIQf/YQr0YW3c9LDKeREWuSx+EswU4eNW3coaJBjCDOxTXG5SK5ZZJ+cDTmCH /u3m3uMUYMICXnTZw9/KMn8H/PoVGVb+BXWs/po8hpXKQ4clVgvZkLq1TTvdTdIp +gktzfgMgRFXPEfEGpFvgZzVcF3QIhs1lH6jL7usto16lzXVryhwQPY/npviM3rs nmbV2DT3XrySYjwDim7WSEUUjGBWht+ZIzz3GeuhgWshV7ItAUDrFvPq86WpEu28 5fz7Dvd5qcm3im3avIdtpg49Jn7zu3HLYhzyqM4Z0PIUASu+hCjiL0eE4QwqpJ06 r3p9Smb+BrehocM6nJUvG38smvF2uQ== =xafN -----END PGP SIGNATURE----- --Sig_/i9ervaoLMS_qzfjvgUCWLqI--