From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id D977840794 for ; Tue, 31 May 2022 03:17:53 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 914C268B658; Tue, 31 May 2022 06:17:52 +0300 (EEST) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7704C68B638 for ; Tue, 31 May 2022 06:17:46 +0300 (EEST) Received: by mail-pj1-f45.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so981705pjq.2 for ; Mon, 30 May 2022 20:17:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandflow-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=aNvvBbCIcj+8CXniyUpXuhf14MatnQ7p7Hct61aEz0w=; b=hUTlyaEPbhgPhfm/6ZLmy7YlPFWl6JiQtl/BiYRuyVQSFufBOAsKIriLlwsvM+/MrQ LialLVSQGpy2H/Yuwpk96N+PL3m5xnpbBRuze0bSjQY0FVQar35YRPHXT8eAuXGsb6bx hIiV4QK7I0VJ6M/sZhAq6SFS2aYSoVksCk0XPEs3IaphQ5fVQIu19SRu1dSLphFCoL/q k9ROreY2LwJ19Q/c8H+MOaqofzWDv6txEULqsdVXZUfqHHmszO0k53sUnK/LDrS+5sXc 0wVfNQgUKgwETIhH6vEB717JSv5IfSRUq7DMe3OR5qI1Egd471hBORUAOM/cjqNKaFGP NCaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=aNvvBbCIcj+8CXniyUpXuhf14MatnQ7p7Hct61aEz0w=; b=nl12o5LQe4Vc9YtlqKWCeY/O1FhYXUo0zSQameyKjsUUgtXuu7gY6UULi05qSfMec4 R7uEm2wuuKoxtgyrBag2Y3c9kZgrx1dsusGEnibj5lDf1NFl+AC9Gwf5Sfl8r/MiD52Z sud1Mrj5w72NhlUDRI46cD+N6Ne1iZrCxIZoxc66EJqf0qKWHgs3fRn90kbISiXYxK2Y loDrofTxLwgob9zgj5q8ZrMv4V86fc8tVzXZSqk1bNxvClTBj7q3dLoA2KZFfCosPIFY SrBq1fls6V+UY5zsTTXAZ6AS6BY6iOnisaupiqqURNnnkfIdG3i2sAFzpnFXCrrFzsuT K/wA== X-Gm-Message-State: AOAM5302oLtZi7RmrBQtSvfH2pZ4+6xQ82VzGHC2NTBVaq7tiAU2ad48 JaK8EnRYwnCAafaapQvkvir7tMEHZFCpjA== X-Google-Smtp-Source: ABdhPJwEns62IgwSVlIbuYYWwwlwOpP904GENFBkzDdxag9EN6UhqPff03G0cxIPKJChMdq7D+UaNA== X-Received: by 2002:a17:902:8303:b0:15f:86f:70a with SMTP id bd3-20020a170902830300b0015f086f070amr60837223plb.5.1653967064694; Mon, 30 May 2022 20:17:44 -0700 (PDT) Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com. [209.85.214.172]) by smtp.gmail.com with ESMTPSA id js24-20020a17090b149800b001df3a251cc2sm480114pjb.4.2022.05.30.20.17.44 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 May 2022 20:17:44 -0700 (PDT) Received: by mail-pl1-f172.google.com with SMTP id n18so11737729plg.5 for ; Mon, 30 May 2022 20:17:44 -0700 (PDT) X-Received: by 2002:a17:90b:4a12:b0:1e3:15ef:81e1 with SMTP id kk18-20020a17090b4a1200b001e315ef81e1mr6056175pjb.246.1653967063953; Mon, 30 May 2022 20:17:43 -0700 (PDT) MIME-Version: 1.0 References: <20220424101409.95486-1-zane@zanevaniperen.com> <20220424101409.95486-2-zane@zanevaniperen.com> <04826f35-e7dd-b74d-f684-37f4ca920a5f@zanevaniperen.com> In-Reply-To: <04826f35-e7dd-b74d-f684-37f4ca920a5f@zanevaniperen.com> From: Pierre-Anthony Lemieux Date: Mon, 30 May 2022 20:17:32 -0700 X-Gmail-Original-Message-ID: Message-ID: To: FFmpeg development discussions and patches Subject: Re: [FFmpeg-devel] [PATCH v2 1/7] avutil/uuid: add utility library for manipulating UUIDs as specified in RFC 4122 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Wed, May 11, 2022 at 8:02 AM Zane van Iperen wrote: > > > > On 10/5/22 23:18, Andreas Rheinhardt wrote: > > >> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu) > >> +{ > >> + int i; > >> + const char *cp; > >> + char buf[3]; > >> + > >> + if ((in_end - in_start) != 36) > >> + return -1; > >> + > >> + for (i = 0, cp = in_start; i < 36; i++, cp++) { > >> + if (i == 8 || i == 13 || i == 18 || i == 23) { > >> + if (*cp == '-') > >> + continue; > >> + return AVERROR(EINVAL); > >> + } > >> + > >> + if (!av_isxdigit(*cp)) > >> + return AVERROR(EINVAL); > >> + } > >> + > >> + buf[2] = '\0'; > >> + for (i = 0, cp = in_start; i < 16; i++) { > >> + if (i == 4 || i == 6 || i == 8 || i == 10) > >> + cp++; > >> + > >> + buf[0] = *cp++; > >> + buf[1] = *cp++; > >> + > >> + errno = 0; > >> + uu[i] = strtoul(buf, NULL, 16); > >> + if (errno) > >> + return AVERROR(errno); > > > > How could this ever happen given that you have already checked that the > > buffer only contains hex digits? And isn't using strtoul a bit overkill > > anyway? I'd just check and parse this stuff in one loop. > > > > Yeah, good point. It's based off libuuid's, which has some time/clock uuid handling > between the two loops. I'll tidy it up in the next few days... hopefully... > > >> +/** > >> + * @file > >> + * UUID parsing and serialization utilities. > >> + * The library treat the UUID as an opaque sequence of 16 unsigned bytes, > > ^ > > s > > Fixed. > > >> +/** > >> + * Parses a string representation of a UUID formatted according to IETF RFC 4122 > >> + * into an AVUUID. The parsing is case-insensitive. The string must be 37 > >> + * characters long, including the terminating NULL character. > > > > NUL, NULL is for pointers. > > > > Changed. > > >> +/** > >> + * Parses a string representation of a UUID formatted according to IETF RFC 4122 > >> + * into an AVUUID. The parsing is case-insensitive. The string must consist of > >> + * 36 characters, i.e. `in_end - in_start == 36` > >> + * > >> + * @param[in] in_start Pointer to the first character of the string representation > >> + * @param[in] in_end Pointer to the character after the last character of the > >> + * string representation. That memory location is never > >> + * accessed > >> + * @param[out] uu AVUUID > >> + * @return A non-zero value in case of an error. > >> + */ > >> +int av_uuid_parse_range(const char *in_start, const char *in_end, AVUUID uu); > > > > This sounds like in_end is actually redundant. Does retaining it improve > > extensibility? > > > > I believe so. The main difference is av_uuid_parse_range() can handle non NUL-termiated > strings. I can just remove the entire last sentence (or change "must" to "should"). I have modified the documentation in v3 of the patchset to emphasize that `in_end - in_start != 36` results in an error. > > >> + > >> +/** > >> + * Serializes a AVUUID into a string representation according to IETF RFC 4122. > >> + * The string is lowercase and always 37 characters long, including the > >> + * terminating NULL character. > >> + * > >> + * @param[in] uu AVUUID > >> + * @param[out] out Pointer to a array of no less than 37 characters. > > ^ > > n > > > > Fixed. > > > >> +/** > >> + * Sets a UUID to nil > >> + * > >> + * @param[in,out] uu UUID to be set to nil > >> + */ > >> +void av_uuid_nil_set(AVUUID uu); > > > > Why are these three functions not static inline? Exporting them seems > > like a waste. > > > > No particular reason, it's easy enough to change. > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".