Received: by 2002:a4a:3008:0:0:0:0:0 with SMTP id q8-v6csp3510093oof; Mon, 10 Sep 2018 16:05:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaq4DFX0NDgFwGjaK5hjRQvP8IS5Kt0+NtlwNrNvlCKhWraKkFVAUkZ0bNBMgSMSnvcwQ57 X-Received: by 2002:a17:902:bd44:: with SMTP id b4-v6mr24207823plx.144.1536620740164; Mon, 10 Sep 2018 16:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536620740; cv=none; d=google.com; s=arc-20160816; b=CErfRvQOpVumLqC5AtvIvgOKlzXBrv/m0pty5ytC2CFLJArwJGvay9V+oyYTm+4lbY DPsVxH4BV/eXCgitfWnU7JJq64l3O4U6tVnN6QmDrqLxDZUKlzZO2S413XKG7f2DGpb0 d+5XEbcqvKfoeudw/AuFmo0SSM2a9wxskRbGJ9LXTz4UY5C+q7t9khHKHAp57mWXl6ht WaNLyRzylc+Gjpxwl8iiT48jgTcHye7GcwOjuQG/J4tXAfet5CiCHM++TifL74Gpqpux 6saVwSsb6L0zKQZdAzN9+QwkP8FXBkA1U3F2xIiHNPYpDDfpt1laOQLuRHAUd73o/bA7 gREA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=lG4a74foRPg/cJ4nTIXdpwEt8H603V+g/flSIfe1ZW8=; b=F7ebzTiY0ZVFSQRTqGlFfW/PBlepHURiEc5qEfjsp5Msk/f8hFa8/sUm4err+IP8H9 4G64JbHh+3rjrhlQKMKL0ETk64sw7odZmZ0TgAOJTQfBRjL7FpnFZDARqCfq9LUdViUt X4Sa6fHiEQyJSqMy1oXEUb0Tb2HvJKTmZxbHEtDb0WibYOB0YZeMjWNjkhYYB04ncR5l xIOvUCPcwPLDnL19SJEb+SA8X0Oh2oaDr/7aPGMfEnzoUTikOJgRDmb7HOg8IqtCFSvo p4YHsABfPsMD7FcsXhyZHc7DWlyMxbVWOw6aNFeMPpJol50OkimsvaHAAQFbT2IscBUV ge5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k6-v6si17921654pgq.503.2018.09.10.16.05.07; Mon, 10 Sep 2018 16:05:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbeIKEBV (ORCPT + 99 others); Tue, 11 Sep 2018 00:01:21 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:46007 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725266AbeIKEBV (ORCPT ); Tue, 11 Sep 2018 00:01:21 -0400 Received: by mail-qk1-f193.google.com with SMTP id z125-v6so15571919qkb.12 for ; Mon, 10 Sep 2018 16:05:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=lG4a74foRPg/cJ4nTIXdpwEt8H603V+g/flSIfe1ZW8=; b=Au34caarrbUlMC/e/dLapOzeoUYWeh8eBZUlWrDuTfTGcOKGtGM3XiMytQGJWYrpdx 3VQN9RRGiyzVxKd6W4J/uWpHKHUMxTIZVKvDKmgVdOMSwCl44sDNGHMjj/e/1qgk/3AL Bi1VNr2NidrE6CpsUJMS/kJ7yW437Mv0BO2Kv3mwZ7ul/MP0Cv/cY1eccHQDDLyMsBS1 Q1A1bGroBvrQNA5jneLFfuLB4rJ/tum8aUdX9ulo6JAUj51Rqy/VTlE14VNcoSiJSi44 wxlck02gViqSG0WF1AxapWfGa3qNuk1TSL1cDo3kjKECiMW5802qzd3SlDAMiCM5fXYs eDWg== X-Gm-Message-State: APzg51D9eSzjhp01uc+9KvzauHMG8A1o8zj88mnGTkAxWUXm8DH2Xgi4 iiD9uyCPLRnBBMop5rma2yynYg== X-Received: by 2002:a37:3309:: with SMTP id z9-v6mr16741371qkz.172.1536620702780; Mon, 10 Sep 2018 16:05:02 -0700 (PDT) Received: from labbott-redhat.redhat.com ([2601:602:9802:a8dc::42c3]) by smtp.gmail.com with ESMTPSA id t36-v6sm10921006qtc.45.2018.09.10.16.05.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Sep 2018 16:05:01 -0700 (PDT) From: Laura Abbott To: Jason Wessel , Daniel Thompson , Arnd Bergmann Cc: Laura Abbott , Greg Kroah-Hartman , kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] misc: kgdbts: Fix restrict error Date: Mon, 10 Sep 2018 16:04:56 -0700 Message-Id: <20180910230456.9220-1-labbott@redhat.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org kgdbts current fails when compiled with restrict: drivers/misc/kgdbts.c: In function ‘configure_kgdbts’: drivers/misc/kgdbts.c:1070:2: error: ‘strcpy’ source argument is the same as destination [-Werror=restrict] strcpy(config, opt); ^~~~~~~~~~~~~~~~~~~ As the error says, config is being used in both the source and destination. Refactor the code to only do the copy when needed. Signed-off-by: Laura Abbott --- drivers/misc/kgdbts.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c index 6193270e7b3d..4447ad68ea39 100644 --- a/drivers/misc/kgdbts.c +++ b/drivers/misc/kgdbts.c @@ -1061,20 +1061,23 @@ static void kgdbts_run_tests(void) configured = 0; } -static int kgdbts_option_setup(char *opt) +static void kgdbts_set_verbose(void) { - if (strlen(opt) >= MAX_CONFIG_LEN) { - printk(KERN_ERR "kgdbts: config string too long\n"); - return -ENOSPC; - } - strcpy(config, opt); - verbose = 0; if (strstr(config, "V1")) verbose = 1; if (strstr(config, "V2")) verbose = 2; +} +static int kgdbts_option_setup(char *opt) +{ + if (strlen(opt) >= MAX_CONFIG_LEN) { + printk(KERN_ERR "kgdbts: config string too long\n"); + return -ENOSPC; + } + strcpy(config, opt); + kgdbts_set_verbose(); return 0; } @@ -1086,9 +1089,7 @@ static int configure_kgdbts(void) if (!strlen(config) || isspace(config[0])) goto noconfig; - err = kgdbts_option_setup(config); - if (err) - goto noconfig; + kgdbts_set_verbose(); final_ack = 0; run_plant_and_detach_test(1); -- 2.17.1