Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759227AbbGHUY0 (ORCPT ); Wed, 8 Jul 2015 16:24:26 -0400 Received: from mail-db3on0060.outbound.protection.outlook.com ([157.55.234.60]:42432 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755378AbbGHUVW (ORCPT ); Wed, 8 Jul 2015 16:21:22 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; vger.kernel.org; dkim=none (message not signed) header.d=none; From: Chris Metcalf To: Linus Torvalds CC: Chris Metcalf , Al Viro , Fabian Frederick , Randy Dunlap , Rickard Strandqvist , , Peter Zijlstra , "David S. Miller" , Frederic Weisbecker , Andrew Morton , Sam Ravnborg , Stephen Rothwell , "Theodore Ts'o" , Grant Likely , Dan Carpenter , Geert Uytterhoeven , Michael Ellerman , Linux Kernel Mailing List , Subject: [PATCH v2 3/3] tile: use global strscpy() rather than private copy Date: Wed, 8 Jul 2015 16:20:45 -0400 Message-ID: <1436386845-11989-4-git-send-email-cmetcalf@ezchip.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1436386845-11989-1-git-send-email-cmetcalf@ezchip.com> References: <1436386845-11989-1-git-send-email-cmetcalf@ezchip.com> X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD040;1:4yeQesHG5g0chT11VVU6P51jB1BRjfZLNnkVwfHnaWk5Wj8Bg+vvJuz28Pacb0TlN6M8OkSb3U+3Jb7YZwnlZatrQbSZMvFWwNjNgPc7z7r4S/e4O34OSx7JTRj5QJCcGsh0aRZpZ0RdOVi1cibOMvYgVulla4PY5QmcLdXUchDOs11nDTG79mGtZX8fz88yNEBxtkDeOInVHS4pIoFLAP3KQ5Ugoipr8ckw3fncuC2MFRU3wM84x5vGns3kx/QNgEt0c6S93poR1vycKnKY6tqbpLHwPpPMRxBcO4gqAMSrNlJVYEx3oc3waygNfWc9PFNKhXmzfF7Jr1MjCuhumnNsiqpG0Ws9+zgYZbD3V2jVQO4+6NMENXs0/x3XoW/ysOGm3gHyON73+e4wtPRNgEpwUrpTL0z900V3KcWfTpqnE0LiKQrxI23Kw+3HPzW0 X-Forefront-Antispam-Report: CIP:12.216.194.146;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(339900001)(199003)(189002)(19580405001)(106466001)(105606002)(19580395003)(92566002)(87936001)(62966003)(575784001)(77156002)(5003940100001)(86362001)(6806004)(110136002)(189998001)(5001960100002)(47776003)(33646002)(85426001)(104016003)(48376002)(2950100001)(50226001)(50466002)(42186005)(229853001)(50986999)(46102003)(76176999)(36756003);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR02MB0781;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; MIME-Version: 1.0 Content-Type: text/plain X-Microsoft-Exchange-Diagnostics: 1;VI1PR02MB0781;2:sk5HciTzsgezglY40U4F/HaAkot/8lkLQRabLEzzAQi0q1xipYPxIxPWvKbKYz7E;3:DZfU6OyU5FIEwD87ltdwvRgT8x1BUiXkZF+VZ/0Br3EzE74Pwimw9WQZhpJSThjYQU/I8JWaxzpjABqotma77JRUIDtDht9UxQpj8vRNEZ6GrC8lMOKyue1a6t1G6x70urUJ5Gqa3DOHhPt71PLwWRV6neO89SERDcVEZWDYCfTDDFqMw+k10+3ibOepdLghB/h7c9ETvoN/H8ghxxPgLb/3qbB52zcJRJotin+VSh7ZmgIPJ6rEHwUbwunTlEJd;25:kIRVpB9pDcr8RMLl6AUEzdUmt3B1DDLzwGyg509V4U2TSd3fuizYiLpB/3PakecgLskDS2OkrkJ20IUXxSiZkaHVHrsnpZC0KOqVNL2BLu72EO6kL0MJ61YozoJdKLzpsJcNtgg5+9VGIrYeZjqg4cNdHz/B+LPUjkw19o2DPoNC4G5s5qR/z1cILoCI6hPTm55zg9TE3zcozM2rvGTJAPaT7BzHx/nULBomxA5xF2xC4gplmY+CQvoEOjFvm0Uuw7dgDp3LfrZXBlH+B8WtQA==;20:pitzbl9U/BrX/YZ9E0TWuNnqEXV7VN5bwuea2fstJoQsIsSs+T+FFmbjg15YlLlX+tX+dAdjLIH7V63eY3FNzaV0IJ1hw8mV/3rZXsH1hsqkxdeZlNEUdZtM7XIsv6cOc+zR4naWLLeRAbfS0hidQtrDyI4hh9ucaVF6Pqkalmk= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0781; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:VI1PR02MB0781;BCL:0;PCL:0;RULEID:;SRVR:VI1PR02MB0781; X-Microsoft-Exchange-Diagnostics: 1;VI1PR02MB0781;4:Aq408kkLf01KTLmpgQccAlUemMx+B/ckhRmDguKM1xodLWJYKkHt+FrwIxA+OkdlhHMD9u0Sl9CAwXCHY3+xyRrxn+JzeP2bUVCXKNSVBcStN0PS3zGiPrJ/P9AQP9Ek55osdtpYSLrsZGKFe0x+gTioNXUkE+vwKAkOOHjknom4CX6n4RVchjQ8JxpUOM6FGvOmb73c4fnN0EA7otuxBnc84AfeFVkJKLp+ohxRiBAa0CkAX1VOKxWSurDmdpENfHD2zmx5NFfY8TRbjggbtPz+AyQvFlQc6iNsibc5zc4= X-Forefront-PRVS: 0631F0BC3D X-Microsoft-Exchange-Diagnostics: 1;VI1PR02MB0781;23:zeuFZU1gTw0PBSyzWGrbP1uUzP51zmJ41QrOqWcIMNE168ffowgs6JScdXZH/EKlTBZ6v6Rj9BIOpOVqpPV0B+H6p7ePh/TV90IdQsawZM+j5Nn4iI8FRM+MDnSAGbFYNdEAVR+6H7m5JGpDpj0fK2f8dkGpriwyr9ZdIpnmP2KcGvL+8SgCOoYFwfv0hLEbbTOwflLE8CE1CqkmjEe/KPkft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YZ7uAN6gVVaE/krrWeeXM3QIZO5bpI/Kg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2015 20:21:16.0301 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR02MB0781 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2871 Lines: 87 Now that strscpy() is a standard API, remove the local copy. Signed-off-by: Chris Metcalf --- arch/tile/gxio/mpipe.c | 33 ++++----------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/arch/tile/gxio/mpipe.c b/arch/tile/gxio/mpipe.c index ee186e13dfe6..f102048d9c0e 100644 --- a/arch/tile/gxio/mpipe.c +++ b/arch/tile/gxio/mpipe.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -29,32 +30,6 @@ /* HACK: Avoid pointless "shadow" warnings. */ #define link link_shadow -/** - * strscpy - Copy a C-string into a sized buffer, but only if it fits - * @dest: Where to copy the string to - * @src: Where to copy the string from - * @size: size of destination buffer - * - * Use this routine to avoid copying too-long strings. - * The routine returns the total number of bytes copied - * (including the trailing NUL) or zero if the buffer wasn't - * big enough. To ensure that programmers pay attention - * to the return code, the destination has a single NUL - * written at the front (if size is non-zero) when the - * buffer is not big enough. - */ -static size_t strscpy(char *dest, const char *src, size_t size) -{ - size_t len = strnlen(src, size) + 1; - if (len > size) { - if (size) - dest[0] = '\0'; - return 0; - } - memcpy(dest, src, len); - return len; -} - int gxio_mpipe_init(gxio_mpipe_context_t *context, unsigned int mpipe_index) { char file[32]; @@ -540,7 +515,7 @@ int gxio_mpipe_link_instance(const char *link_name) if (!context) return GXIO_ERR_NO_DEVICE; - if (strscpy(name.name, link_name, sizeof(name.name)) == 0) + if (strscpy(name.name, link_name, sizeof(name.name)) < 0) return GXIO_ERR_NO_DEVICE; return gxio_mpipe_info_instance_aux(context, name); @@ -559,7 +534,7 @@ int gxio_mpipe_link_enumerate_mac(int idx, char *link_name, uint8_t *link_mac) rv = gxio_mpipe_info_enumerate_aux(context, idx, &name, &mac); if (rv >= 0) { - if (strscpy(link_name, name.name, sizeof(name.name)) == 0) + if (strscpy(link_name, name.name, sizeof(name.name)) < 0) return GXIO_ERR_INVAL_MEMORY_SIZE; memcpy(link_mac, mac.mac, sizeof(mac.mac)); } @@ -576,7 +551,7 @@ int gxio_mpipe_link_open(gxio_mpipe_link_t *link, _gxio_mpipe_link_name_t name; int rv; - if (strscpy(name.name, link_name, sizeof(name.name)) == 0) + if (strscpy(name.name, link_name, sizeof(name.name)) < 0) return GXIO_ERR_NO_DEVICE; rv = gxio_mpipe_link_open_aux(context, name, flags); -- 2.1.2 -- 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/