From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by mx.groups.io with SMTP id smtpd.web09.3535.1639345230061525755 for ; Sun, 12 Dec 2021 13:40:30 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@nuviainc-com.20210112.gappssmtp.com header.s=20210112 header.b=71kcNpCq; spf=pass (domain: nuviainc.com, ip: 209.85.216.43, mailfrom: rebecca@nuviainc.com) Received: by mail-pj1-f43.google.com with SMTP id gf14-20020a17090ac7ce00b001a7a2a0b5c3so13265889pjb.5 for ; Sun, 12 Dec 2021 13:40:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nuviainc-com.20210112.gappssmtp.com; s=20210112; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=DoBkvf9XJxLNXwW73KfggxWvnTO9y4HBXhSSCGN5ih8=; b=71kcNpCqLOqo4s0e8/16c8i5oFF/ytgDTBVcaFYUjZ3nzqrYLordLKoGAiwXHXQ1SE mQ0WhGnBh45vi5wN+r9IS4QTAOI6LkxQcHpAwMZbj0yY+JTX7XbFjQuVkFTL3hW82j13 shbehSgUvf1CZhGmcid+/MkM28tXmZ5/AtN2YrpppRYL6btVypjQ1OXnM1r7atl8YlpP udg8CVvnUhSy5XgJvoQPexQCUX7nbvDOcCeNb9ovTWCTMCxGWr/FoEySVViIFIrVZjHI TnvvB/CdtBPng2cSeuUB9C+h5Wi1WHIQEJxkQaJmT/iGN0QD7s/qtj89vXW95fd86Ypo zayw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=DoBkvf9XJxLNXwW73KfggxWvnTO9y4HBXhSSCGN5ih8=; b=WSbImAftuiNid/ovbYssS7EuSV+TC8hFu8SR2h6GZ+y9UUV+ISoBqigj6EDYuOiM2x hER4P9suaZuQsI4nseDNPH4hc20RE/NAc5xIy3mgVAGrtuZiAQOr/JvVgPUldfUe31EB vMQvpt+qmqF+Z5bXT7HiUcltFuI9PpFAH6ErI//xzWv2cYnQ++jD0Nx9oKTP8QOJqVkF SwvVNlXzjJAt6e3coh5gaUsDucGmo7GMbengX+D9mK87Qb9wg4n93VLCvzqrQiqmj8OP QgLcw4eVgAHevnHkakvOqUXysgg4fLobsjOnBAXPPNzqTGh3YvqHEMkyUAGPco8FjvEZ a/Ow== X-Gm-Message-State: AOAM530CG8SXR9a9eZ9fDsHut507YHzLh7dxetMlbqccJ5awSF/a8OhF Bh7RFAIx3laa5/KR3aSO5sYuFQ== X-Google-Smtp-Source: ABdhPJxswbIFfnGe3bz/TnZn9QlWCGW+/uIA+PiI87axibJGzTMTG8Ngtg4FTC5kMsw/IkHGMsSsVQ== X-Received: by 2002:a17:90a:7e89:: with SMTP id j9mr15425443pjl.162.1639345229577; Sun, 12 Dec 2021 13:40:29 -0800 (PST) Return-Path: Received: from ?IPv6:2601:681:4300:69e:9e7b:efff:fe2b:884c? ([2601:681:4300:69e:9e7b:efff:fe2b:884c]) by smtp.gmail.com with ESMTPSA id u22sm10650723pfk.148.2021.12.12.13.40.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Dec 2021 13:40:29 -0800 (PST) Subject: Re: [edk2-devel] [PATCH] StdLib/LibC: add strnlen function wrapper To: devel@edk2.groups.io, mateusz.mowka@intel.com Cc: Caleb Reister , Rebecca Cran , Michael D Kinney References: <20211103084455.468-1-mateusz.mowka@intel.com> From: "Rebecca Cran" Message-ID: <38e65009-1e6f-5dd0-72e0-75c5fdbe9473@nuviainc.com> Date: Sun, 12 Dec 2021 14:40:27 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20211103084455.468-1-mateusz.mowka@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sorry for the delay. You should probably use the same doxygen header in both the .h and .c files, with the @param lines. -- Rebecca Cran On 11/3/21 2:44 AM, mateusz.mowka@intel.com wrote: > From: mateusz-mowka > > This patch adds strnlen function wrapper that internally calls > AsciiStrnLenS, which is defined in BaseLib. > > Cc: Caleb Reister > Cc: Rebecca Cran > Cc: Michael D Kinney > > Signed-off-by: Mateusz Mówka > --- > StdLib/Include/string.h | 11 +++++++++++ > StdLib/LibC/String/Misc.c | 12 ++++++++++++ > 2 files changed, 23 insertions(+) > > diff --git a/StdLib/Include/string.h b/StdLib/Include/string.h > index 0c80944..07652ca 100644 > --- a/StdLib/Include/string.h > +++ b/StdLib/Include/string.h > @@ -62,6 +62,7 @@ > void *memset (void *s, int c, size_t n); > char *strerror (int num); > size_t strlen (const char *); > + size_t strnlen (const char, size_t n) > > ################ BSD Compatibility Functions > char *strdup (const char *); > @@ -454,6 +455,16 @@ char *strerror(int Num); > **/ > size_t strlen(const char *S); > > +/** The strnlen function computes the length of a fixed-size string. > + > + @param[in] S Pointer to the string to determine the length of. > + @param[in] N Length of a string including the terminating character. > + > + @return The strnlen function returns the number of characters that > + precede the terminating null character but not exceeding N. > +**/ > +size_t strnlen(const char *S, size_t N); > + > > /* ################ BSD Compatibility Functions ####################### */ > > diff --git a/StdLib/LibC/String/Misc.c b/StdLib/LibC/String/Misc.c > index f024136..cf680e3 100644 > --- a/StdLib/LibC/String/Misc.c > +++ b/StdLib/LibC/String/Misc.c > @@ -99,3 +99,15 @@ strlen(const char *s) > { > return (size_t)AsciiStrLen( s); > } > + > +/** The strnlen function computes the length of the string pointed to by s > + but at most n > + > + @return The strnlen function returns the number of characters that > + precede the terminating null character but at most n. > +**/ > +size_t > +strnlen(const char *s, size_t n) > +{ > + return (size_t)AsciiStrnLenS( s, n); > +}