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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 13192 invoked from network); 26 May 2023 13:43:33 -0000 Received: from lists.zx2c4.com (165.227.139.114) by inbox.vuxu.org with ESMTPUTF8; 26 May 2023 13:43:33 -0000 Received: by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d2239aa2; Fri, 26 May 2023 13:43:16 +0000 (UTC) Return-Path: Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lists.zx2c4.com (ZX2C4 Mail Server) with ESMTPS id b77dbbb5 (TLSv1.2:ECDHE-ECDSA-AES256-GCM-SHA384:256:NO) for ; Fri, 26 May 2023 13:43:14 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E95BA64C99 for ; Fri, 26 May 2023 13:43:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DED08C4339B for ; Fri, 26 May 2023 13:43:11 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="c6kdxVnW" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1685108589; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rZsFlcUGRN/GXLtX4i4TEMHn9JZBqqnvUrLMn8u1PYM=; b=c6kdxVnWHqzddlLj6TA6AgeYsgqgEt693Fvyfyt0XmzowQTncdhMNYxXZtsZlNqQGhSFhG Yk+BUd8c9ULjFeKLSjmRWBwGPEQImFnFB5BFcV9JY0mmK9HDCk34rqazyuqRDk4BSevGNz 3ANAQE1W4CjYW/0Ww4KJ2ZDCSO2eICA= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 4423aeaf (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Fri, 26 May 2023 13:43:07 +0000 (UTC) Received: by mail-vs1-f53.google.com with SMTP id ada2fe7eead31-439554d9a69so641818137.1 for ; Fri, 26 May 2023 06:43:07 -0700 (PDT) X-Gm-Message-State: AC+VfDyJ4lQdKBZsKl6HNPHRWw2E9WnXpWXsjOcZCgKIsW/YhuN/oDqo QiF1UhDnCHu5pBTCFQCgNvl2PRxugpz80dsaaUk= X-Google-Smtp-Source: ACHHUZ7UjMWg9caUj64sMvOWF32tNtpz5jwz2/uO4zvO3K9AiCsxsIkHPENNpUABtHAsuCv7Y3XKUEcZ1eKTpes8MNY= X-Received: by 2002:a05:6102:3b09:b0:434:5810:32a6 with SMTP id x9-20020a0561023b0900b00434581032a6mr2092436vsu.8.1685108586463; Fri, 26 May 2023 06:43:06 -0700 (PDT) MIME-Version: 1.0 References: <20230526110646.60621-1-list@eworm.de> In-Reply-To: <20230526110646.60621-1-list@eworm.de> From: "Jason A. Donenfeld" Date: Fri, 26 May 2023 15:42:55 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/1] RFC: git: update to v2.41.0-rc2 To: list@eworm.de Cc: cgit@lists.zx2c4.com, Christian Hesse Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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" On Fri, May 26, 2023 at 1:07=E2=80=AFPM Christian Hesse wro= te: > @@ -564,9 +566,11 @@ char *get_mimetype_for_filename(const char *filename= ) > 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); > } 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? Jason