From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Thu, 25 Mar 2021 15:40:44 +1300 Subject: [PATCH v2 1/5] lib: string: Fix strlcpy return value In-Reply-To: References: <20210311051545.1886333-1-seanga2@gmail.com> <20210311051545.1886333-2-seanga2@gmail.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Sean, On Thu, 25 Mar 2021 at 13:54, Sean Anderson wrote: > > On 3/24/21 8:38 PM, Simon Glass wrote: > > Hi Sean, > > > > On Thu, 11 Mar 2021 at 18:15, Sean Anderson wrote: > >> > >> strlcpy should always return the number of bytes copied. We were > >> accidentally missing the nul-terminator. We also always used to return a > >> non-zero value, even if we did not actually copy anything. > >> > >> Fixes: 23cd138503 ("Integrate USB gadget layer and USB CDC driver layer") > >> > >> Signed-off-by: Sean Anderson > >> --- > >> > >> Changes in v2: > >> - New > >> > >> lib/string.c | 12 ++++++++---- > >> 1 file changed, 8 insertions(+), 4 deletions(-) > > > > Please can you add a test while you are here? Might be easier on the > > -next branch. > > This is tested in patch 3 as strlcat is implemented with strlcpy. Though > it looks like I will need to change the implementation... Yes but I still think it is good to have a few simple test for this function .Transitive tests are quite a bit harder to understand. Perhaps just 3-4 cases? Regards, Simon