Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7095600ybi; Thu, 13 Jun 2019 09:28:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9ScvcTKgRc2inDHm+5Sda63YwLel5qcle49UlcC8OyD6PK19sZO6fFhu9MZM1+iE3zlF5 X-Received: by 2002:a63:5009:: with SMTP id e9mr30897234pgb.396.1560443289382; Thu, 13 Jun 2019 09:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560443289; cv=none; d=google.com; s=arc-20160816; b=t01B8/21HBzUBwJi6jCFTcvMrXMWqe1XDb0AuCdToaqR2VFoxhFFruQ6G6J8pBlxMI nkfk0B6yW5cN1Qf50Fg7QslBN7VYms60WFERzyBy0kcue1kXygT/2dJLxn6THyjX8B29 NMWGhp4OitnYELMuBhwPptF1QAJuRyWC0dtRZQ5UAbCFmWViDzAqGpx36rxRwhAcyKtD qesR0WwU6JAQI03MusD1ipnqMXSHDnzyKhNbuLBrV+Ft9QoJOW6Pu56vzbtGgwHHDyfA N6wRlVSfaHPYBDv/ymtSpVUN96X2qH5Zlnp4sbrY/Dm6TRZxXLOtNIlVtBbOHcwtR3ud 1d+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=Vx9IHJc4hd8+3je17qLZvUlArSvu458iUM0jn0iMuYk=; b=BektAtdv6SGp4ZNU/yFCBgH8CwwgAhBFwvF16+bbM36jEkWOKvhf66k0EYvSgl+lP1 6gBp1g9OUCKfKSs4oVvoAJu2xx/JYVKbMc/+KnfIrXGfVfPA0xkG7xqYkB9SZIJUhbuz Hj3FaVcuDTwgcrp6yZA6VpPZ5zaBpw3thYKfnK3Qq1c7AK4DfCqmL0pzwzzp1ZXNpEJX 6vV1Bihh/+A1OfVsnH9NgokaH9E+MhT/Ur/M1XDrZ9aC/qv9bQ8A+ZAZHSV4x6RT7LGx 0Z+8kDWwKfUWOuiJRT7QGj1sy0/IrPT1OUK0C2dd5cWVIauELH+iCucOQgJDb7WNVeDq 4xLA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12si41437pjq.67.2019.06.13.09.27.54; Thu, 13 Jun 2019 09:28:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392277AbfFMQ0B (ORCPT + 99 others); Thu, 13 Jun 2019 12:26:01 -0400 Received: from smtp5-g21.free.fr ([212.27.42.5]:34420 "EHLO smtp5-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730967AbfFMQ0A (ORCPT ); Thu, 13 Jun 2019 12:26:00 -0400 Received: from heffalump.sk2.org (unknown [88.186.243.14]) by smtp5-g21.free.fr (Postfix) with ESMTPS id E012F5FFD3; Thu, 13 Jun 2019 18:25:57 +0200 (CEST) Received: from steve by heffalump.sk2.org with local (Exim 4.89) (envelope-from ) id 1hbSY0-0005A0-Vs; Thu, 13 Jun 2019 18:25:57 +0200 From: Stephen Kitt To: corbet@lwn.net, federico.vaga@vaga.pv.it, linux-doc@vger.kernel.org Cc: keescook@chromium.org, linux-kernel@vger.kernel.org, Stephen Kitt Subject: [PATCH] docs: stop suggesting strlcpy Date: Thu, 13 Jun 2019 18:25:48 +0200 Message-Id: <20190613162548.19792-1-steve@sk2.org> X-Mailer: git-send-email 2.11.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since strlcpy is deprecated, the documentation shouldn't suggest using it. This patch fixes the examples to use strscpy instead. It also uses sizeof instead of underlying constants as far as possible, to simplify future changes to the corresponding data structures. Signed-off-by: Stephen Kitt --- Documentation/hid/hid-transport.txt | 6 +++--- Documentation/i2c/instantiating-devices | 2 +- Documentation/i2c/upgrading-clients | 4 ++-- Documentation/kernel-hacking/locking.rst | 6 +++--- Documentation/translations/it_IT/kernel-hacking/locking.rst | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Documentation/hid/hid-transport.txt b/Documentation/hid/hid-transport.txt index 3dcba9fd4a3a..4f41d67f1b4b 100644 --- a/Documentation/hid/hid-transport.txt +++ b/Documentation/hid/hid-transport.txt @@ -194,9 +194,9 @@ with HID core: goto err_<...>; } - strlcpy(hid->name, , 127); - strlcpy(hid->phys, , 63); - strlcpy(hid->uniq, , 63); + strscpy(hid->name, , sizeof(hid->name)); + strscpy(hid->phys, , sizeof(hid->phys)); + strscpy(hid->uniq, , sizeof(hid->uniq)); hid->ll_driver = &custom_ll_driver; hid->bus = ; diff --git a/Documentation/i2c/instantiating-devices b/Documentation/i2c/instantiating-devices index 0d85ac1935b7..8bc7d99133e3 100644 --- a/Documentation/i2c/instantiating-devices +++ b/Documentation/i2c/instantiating-devices @@ -137,7 +137,7 @@ static int usb_hcd_nxp_probe(struct platform_device *pdev) (...) i2c_adap = i2c_get_adapter(2); memset(&i2c_info, 0, sizeof(struct i2c_board_info)); - strlcpy(i2c_info.type, "isp1301_nxp", I2C_NAME_SIZE); + strscpy(i2c_info.type, "isp1301_nxp", sizeof(i2c_info.type)); isp1301_i2c_client = i2c_new_probed_device(i2c_adap, &i2c_info, normal_i2c, NULL); i2c_put_adapter(i2c_adap); diff --git a/Documentation/i2c/upgrading-clients b/Documentation/i2c/upgrading-clients index ccba3ffd6e80..96392cc5b5c7 100644 --- a/Documentation/i2c/upgrading-clients +++ b/Documentation/i2c/upgrading-clients @@ -43,7 +43,7 @@ static int example_attach(struct i2c_adapter *adap, int addr, int kind) example->client.adapter = adap; i2c_set_clientdata(&state->i2c_client, state); - strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE); + strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); ret = i2c_attach_client(&state->i2c_client); if (ret < 0) { @@ -138,7 +138,7 @@ can be removed: - example->client.flags = 0; - example->client.adapter = adap; - -- strlcpy(client->i2c_client.name, "example", I2C_NAME_SIZE); +- strscpy(client->i2c_client.name, "example", sizeof(client->i2c_client.name)); The i2c_set_clientdata is now: diff --git a/Documentation/kernel-hacking/locking.rst b/Documentation/kernel-hacking/locking.rst index 519673df0e82..dc698ea456e0 100644 --- a/Documentation/kernel-hacking/locking.rst +++ b/Documentation/kernel-hacking/locking.rst @@ -451,7 +451,7 @@ to protect the cache and all the objects within it. Here's the code:: if ((obj = kmalloc(sizeof(*obj), GFP_KERNEL)) == NULL) return -ENOMEM; - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; @@ -660,7 +660,7 @@ Here is the code:: } @@ -63,6 +94,7 @@ - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; + obj->refcnt = 1; /* The cache holds a reference */ @@ -774,7 +774,7 @@ the lock is no longer used to protect the reference count itself. } @@ -94,7 +76,7 @@ - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; - obj->refcnt = 1; /* The cache holds a reference */ diff --git a/Documentation/translations/it_IT/kernel-hacking/locking.rst b/Documentation/translations/it_IT/kernel-hacking/locking.rst index 0ef31666663b..5fd8a1abd2be 100644 --- a/Documentation/translations/it_IT/kernel-hacking/locking.rst +++ b/Documentation/translations/it_IT/kernel-hacking/locking.rst @@ -468,7 +468,7 @@ e tutti gli oggetti che contiene. Ecco il codice:: if ((obj = kmalloc(sizeof(*obj), GFP_KERNEL)) == NULL) return -ENOMEM; - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; @@ -678,7 +678,7 @@ Ecco il codice:: } @@ -63,6 +94,7 @@ - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; + obj->refcnt = 1; /* The cache holds a reference */ @@ -792,7 +792,7 @@ contatore stesso. } @@ -94,7 +76,7 @@ - strlcpy(obj->name, name, sizeof(obj->name)); + strscpy(obj->name, name, sizeof(obj->name)); obj->id = id; obj->popularity = 0; - obj->refcnt = 1; /* The cache holds a reference */ -- 2.11.0