From: David Carlier <[email protected]>
Check the return value of da_atlas_getproptype() and skip the property
on failure instead of using an uninitialized proptype. Also remove the
unnecessary pprop pointer indirection, using prop directly.
---
addons/deviceatlas/da.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/addons/deviceatlas/da.c b/addons/deviceatlas/da.c
index 676d4222c..c5d558521 100644
--- a/addons/deviceatlas/da.c
+++ b/addons/deviceatlas/da.c
@@ -324,7 +324,7 @@ static void da_haproxy_checkinst(void)
static int da_haproxy(const struct arg *args, struct sample *smp,
da_deviceinfo_t *devinfo)
{
struct buffer *tmp;
- da_propid_t prop, *pprop;
+ da_propid_t prop;
da_status_t status;
da_type_t proptype;
const char *propname;
@@ -344,13 +344,15 @@ static int da_haproxy(const struct arg *args, struct
sample *smp, da_deviceinfo_
chunk_appendf(tmp, "%c", global_deviceatlas.separator);
continue;
}
- pprop = ∝
- da_atlas_getproptype(&global_deviceatlas.atlas, *pprop,
&proptype);
+ if (unlikely(da_atlas_getproptype(&global_deviceatlas.atlas,
prop, &proptype) != DA_OK)) {
+ chunk_appendf(tmp, "%c", global_deviceatlas.separator);
+ continue;
+ }
switch (proptype) {
case DA_TYPE_BOOLEAN: {
bool val;
- status = da_getpropboolean(devinfo, *pprop,
&val);
+ status = da_getpropboolean(devinfo, prop, &val);
if (status == DA_OK) {
chunk_appendf(tmp, "%d", val);
}
@@ -359,7 +361,7 @@ static int da_haproxy(const struct arg *args, struct sample
*smp, da_deviceinfo_
case DA_TYPE_INTEGER:
case DA_TYPE_NUMBER: {
long val;
- status = da_getpropinteger(devinfo, *pprop,
&val);
+ status = da_getpropinteger(devinfo, prop, &val);
if (status == DA_OK) {
chunk_appendf(tmp, "%ld", val);
}
@@ -367,7 +369,7 @@ static int da_haproxy(const struct arg *args, struct sample
*smp, da_deviceinfo_
}
case DA_TYPE_STRING: {
const char *val;
- status = da_getpropstring(devinfo, *pprop,
&val);
+ status = da_getpropstring(devinfo, prop, &val);
if (status == DA_OK) {
chunk_appendf(tmp, "%s", val);
}
--
2.51.0