Skip to content

Commit 6339506

Browse files
dlechjic23
authored andcommitted
iio: chemical: sunrise_co2: use = { } instead of memset()
Use { } instead of memset() to zero-initialize stack memory to simplify the code. Signed-off-by: David Lechner <dlechner@baylibre.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20250611-iio-zero-init-stack-with-instead-of-memset-v1-14-ebb2d0a24302@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
1 parent 62c7683 commit 6339506

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/iio/chemical/sunrise_co2.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,12 @@ static int sunrise_regmap_read(void *context, const void *reg_buf,
5151
{
5252
struct i2c_client *client = context;
5353
struct sunrise_dev *sunrise = i2c_get_clientdata(client);
54-
union i2c_smbus_data data;
54+
union i2c_smbus_data data = { };
5555
int ret;
5656

5757
if (reg_size != 1 || !val_size)
5858
return -EINVAL;
5959

60-
memset(&data, 0, sizeof(data));
6160
data.block[0] = val_size;
6261

6362
/*
@@ -88,14 +87,13 @@ static int sunrise_regmap_write(void *context, const void *val_buf, size_t count
8887
{
8988
struct i2c_client *client = context;
9089
struct sunrise_dev *sunrise = i2c_get_clientdata(client);
91-
union i2c_smbus_data data;
90+
union i2c_smbus_data data = { };
9291

9392
/* Discard reg address from values count. */
9493
if (!count)
9594
return -EINVAL;
9695
count--;
9796

98-
memset(&data, 0, sizeof(data));
9997
data.block[0] = count;
10098
memcpy(&data.block[1], (u8 *)val_buf + 1, count);
10199

0 commit comments

Comments
 (0)