1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #10729 from keestux/replace-memset

drivers: replace memset by simple assignments
This commit is contained in:
Sebastian Meiling 2019-01-08 14:26:23 +01:00 committed by GitHub
commit 838284f979
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 7 deletions

View File

@ -47,7 +47,8 @@ static int check_and_read(const void *dev, phydat_t *res, int16_t *val, uint8_t
} }
res->val[0] = *val; res->val[0] = *val;
memset(&res->val[1], 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = unit; res->unit = unit;
res->scale = -1; res->scale = -1;
return 1; return 1;

View File

@ -28,7 +28,8 @@ static int read_temp(const void *dev, phydat_t *res)
if (hdc1000_read_cached((const hdc1000_t *)dev, &(res->val[0]), NULL) != HDC1000_OK) { if (hdc1000_read_cached((const hdc1000_t *)dev, &(res->val[0]), NULL) != HDC1000_OK) {
return -ECANCELED; return -ECANCELED;
} }
memset(&(res->val[1]), 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = UNIT_TEMP_C; res->unit = UNIT_TEMP_C;
res->scale = -2; res->scale = -2;
@ -40,7 +41,8 @@ static int read_hum(const void *dev, phydat_t *res)
if (hdc1000_read_cached((const hdc1000_t *)dev, NULL, &(res->val[0])) != HDC1000_OK) { if (hdc1000_read_cached((const hdc1000_t *)dev, NULL, &(res->val[0])) != HDC1000_OK) {
return -ECANCELED; return -ECANCELED;
} }
memset(&(res->val[1]), 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = UNIT_PERCENT; res->unit = UNIT_PERCENT;
res->scale = -2; res->scale = -2;

View File

@ -26,7 +26,8 @@
static int read(const void *dev, phydat_t *res) static int read(const void *dev, phydat_t *res)
{ {
res->val[0] = (int16_t)isl29020_read((const isl29020_t *)dev); res->val[0] = (int16_t)isl29020_read((const isl29020_t *)dev);
memset(&(res->val[1]), 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = UNIT_CD; res->unit = UNIT_CD;
res->scale = 0; res->scale = 0;
return 1; return 1;

View File

@ -29,7 +29,8 @@ static int read_occup(const void *dev, phydat_t *res) {
/* Read failure */ /* Read failure */
return -ECANCELED; return -ECANCELED;
} }
memset(&(res->val[1]), 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = UNIT_PERCENT; res->unit = UNIT_PERCENT;
res->scale = -2; res->scale = -2;
return 1; return 1;

View File

@ -30,7 +30,8 @@ static int read_adc(const void *dev, phydat_t *res)
{ {
const saul_adc_params_t *params = *((const saul_adc_params_t **)dev); const saul_adc_params_t *params = *((const saul_adc_params_t **)dev);
res->val[0] = adc_sample(params->line, params->res); res->val[0] = adc_sample(params->line, params->res);
memset(&(res->val[1]), 0, 2 * sizeof(res->val[1])); res->val[1] = 0;
res->val[2] = 0;
/* Raw ADC reading has no unit */ /* Raw ADC reading has no unit */
res->unit = UNIT_NONE; res->unit = UNIT_NONE;
res->scale = 0; res->scale = 0;

View File

@ -33,7 +33,8 @@ static int read(const void *dev, phydat_t *res)
res->val[0] = (gpio_read(p->pin)) ? !inverted : inverted; res->val[0] = (gpio_read(p->pin)) ? !inverted : inverted;
memset(&(res->val[1]), 0, 2 * sizeof(int16_t)); res->val[1] = 0;
res->val[2] = 0;
res->unit = UNIT_BOOL; res->unit = UNIT_BOOL;
res->scale = 0; res->scale = 0;
return 1; return 1;