Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752750AbbEFPCz (ORCPT ); Wed, 6 May 2015 11:02:55 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:30659 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751147AbbEFPCw (ORCPT ); Wed, 6 May 2015 11:02:52 -0400 Date: Wed, 6 May 2015 18:01:40 +0300 From: Dan Carpenter To: Chris Metcalf Cc: Linus Torvalds , Al Viro , Fabian Frederick , Randy Dunlap , Rickard Strandqvist , gregkh@linuxfoundation.org, Peter Zijlstra , "David S. Miller" , Frederic Weisbecker , Andrew Morton , Sam Ravnborg , Stephen Rothwell , "Theodore Ts'o" , Grant Likely , Linux Kernel Mailing List , linux-arch@vger.kernel.org Subject: Re: [PATCH 2/3] string: provide strscpy() and strscpy_truncate() Message-ID: <20150506150140.GB12986@mwanda> References: <1430409677-13284-1-git-send-email-cmetcalf@ezchip.com> <1430409677-13284-3-git-send-email-cmetcalf@ezchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1430409677-13284-3-git-send-email-cmetcalf@ezchip.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 653 Lines: 20 On Thu, Apr 30, 2015 at 12:01:16PM -0400, Chris Metcalf wrote: > +ssize_t strscpy(char *dest, const char *src, size_t count) > +{ > + ssize_t res = strscpy_truncate(dest, src, count); > + if (res < 0 && count != 0) > + dest[0] = '\0'; How is this better than returning a truncated string? Is it just because the caller was naughty so we give them a spanking? > + return res; > +} regards, dan carpenter -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/