mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
crypto: qat - use 2-arg strscpy where destination size is known
To simplify the code, drop explicit and hard-coded size arguments from strscpy() where the destination buffer has a fixed size and strscpy() can automatically determine it using sizeof(). Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
dea300a465
commit
4525ac1411
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright(c) 2014 - 2020 Intel Corporation */
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include "adf_accel_devices.h"
|
||||
|
|
@ -284,13 +285,13 @@ int adf_cfg_add_key_value_param(struct adf_accel_dev *accel_dev,
|
|||
return -ENOMEM;
|
||||
|
||||
INIT_LIST_HEAD(&key_val->list);
|
||||
strscpy(key_val->key, key, sizeof(key_val->key));
|
||||
strscpy(key_val->key, key);
|
||||
|
||||
if (type == ADF_DEC) {
|
||||
snprintf(key_val->val, ADF_CFG_MAX_VAL_LEN_IN_BYTES,
|
||||
"%ld", (*((long *)val)));
|
||||
} else if (type == ADF_STR) {
|
||||
strscpy(key_val->val, (char *)val, sizeof(key_val->val));
|
||||
strscpy(key_val->val, (char *)val);
|
||||
} else if (type == ADF_HEX) {
|
||||
snprintf(key_val->val, ADF_CFG_MAX_VAL_LEN_IN_BYTES,
|
||||
"0x%lx", (unsigned long)val);
|
||||
|
|
@ -350,7 +351,7 @@ int adf_cfg_section_add(struct adf_accel_dev *accel_dev, const char *name)
|
|||
if (!sec)
|
||||
return -ENOMEM;
|
||||
|
||||
strscpy(sec->name, name, sizeof(sec->name));
|
||||
strscpy(sec->name, name);
|
||||
INIT_LIST_HEAD(&sec->param_head);
|
||||
down_write(&cfg->lock);
|
||||
list_add_tail(&sec->list, &cfg->sec_list);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ static int adf_service_string_to_mask(struct adf_accel_dev *accel_dev, const cha
|
|||
if (len > ADF_CFG_MAX_VAL_LEN_IN_BYTES - 1)
|
||||
return -EINVAL;
|
||||
|
||||
strscpy(services, buf, ADF_CFG_MAX_VAL_LEN_IN_BYTES);
|
||||
strscpy(services, buf);
|
||||
substr = services;
|
||||
|
||||
while ((token = strsep(&substr, ADF_SERVICES_DELIMITER))) {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright(c) 2024 Intel Corporation */
|
||||
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/types.h>
|
||||
#include "adf_mstate_mgr.h"
|
||||
|
||||
|
|
@ -158,7 +159,7 @@ static struct adf_mstate_sect_h *adf_mstate_sect_add_header(struct adf_mstate_mg
|
|||
return NULL;
|
||||
}
|
||||
|
||||
strscpy(sect->id, id, sizeof(sect->id));
|
||||
strscpy(sect->id, id);
|
||||
sect->size = 0;
|
||||
sect->sub_sects = 0;
|
||||
mgr->state += sizeof(*sect);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright(c) 2014 - 2020 Intel Corporation */
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include "adf_accel_devices.h"
|
||||
#include "adf_transport_internal.h"
|
||||
|
|
@ -103,7 +104,7 @@ int adf_ring_debugfs_add(struct adf_etr_ring_data *ring, const char *name)
|
|||
if (!ring_debug)
|
||||
return -ENOMEM;
|
||||
|
||||
strscpy(ring_debug->ring_name, name, sizeof(ring_debug->ring_name));
|
||||
strscpy(ring_debug->ring_name, name);
|
||||
snprintf(entry_name, sizeof(entry_name), "ring_%02d",
|
||||
ring->ring_number);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
/* Copyright(c) 2022 Intel Corporation */
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/string.h>
|
||||
#include "adf_accel_devices.h"
|
||||
#include "adf_common_drv.h"
|
||||
#include "adf_transport.h"
|
||||
|
|
@ -144,7 +145,7 @@ static int qat_compression_create_instances(struct adf_accel_dev *accel_dev)
|
|||
int i;
|
||||
|
||||
INIT_LIST_HEAD(&accel_dev->compression_list);
|
||||
strscpy(key, ADF_NUM_DC, sizeof(key));
|
||||
strscpy(key, ADF_NUM_DC);
|
||||
ret = adf_cfg_get_param_value(accel_dev, SEC, key, val);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user