Commit 20f9b9d3 authored by Przemek Kitszel's avatar Przemek Kitszel Committed by David S. Miller

netdevsim: devlink health: use retained error fmsg API

Drop unneeded error checking.

devlink_fmsg_*() family of functions is now retaining errors,
so there is no need to check for them after each call.
Reviewed-by: default avatarJesse Brandeburg <jesse.brandeburg@intel.com>
Reviewed-by: default avatarJiri Pirko <jiri@nvidia.com>
Reviewed-by: default avatarJakub Kicinski <kuba@kernel.org>
Signed-off-by: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent db80d3b2
...@@ -63,91 +63,45 @@ nsim_dev_dummy_reporter_recover(struct devlink_health_reporter *reporter, ...@@ -63,91 +63,45 @@ nsim_dev_dummy_reporter_recover(struct devlink_health_reporter *reporter,
static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len) static int nsim_dev_dummy_fmsg_put(struct devlink_fmsg *fmsg, u32 binary_len)
{ {
char *binary; char *binary;
int err;
int i; int i;
err = devlink_fmsg_bool_pair_put(fmsg, "test_bool", true); devlink_fmsg_bool_pair_put(fmsg, "test_bool", true);
if (err) devlink_fmsg_u8_pair_put(fmsg, "test_u8", 1);
return err; devlink_fmsg_u32_pair_put(fmsg, "test_u32", 3);
err = devlink_fmsg_u8_pair_put(fmsg, "test_u8", 1); devlink_fmsg_u64_pair_put(fmsg, "test_u64", 4);
if (err) devlink_fmsg_string_pair_put(fmsg, "test_string", "somestring");
return err;
err = devlink_fmsg_u32_pair_put(fmsg, "test_u32", 3);
if (err)
return err;
err = devlink_fmsg_u64_pair_put(fmsg, "test_u64", 4);
if (err)
return err;
err = devlink_fmsg_string_pair_put(fmsg, "test_string", "somestring");
if (err)
return err;
binary = kmalloc(binary_len, GFP_KERNEL | __GFP_NOWARN); binary = kmalloc(binary_len, GFP_KERNEL | __GFP_NOWARN);
if (!binary) if (!binary)
return -ENOMEM; return -ENOMEM;
get_random_bytes(binary, binary_len); get_random_bytes(binary, binary_len);
err = devlink_fmsg_binary_pair_put(fmsg, "test_binary", binary, binary_len); devlink_fmsg_binary_pair_put(fmsg, "test_binary", binary, binary_len);
kfree(binary); kfree(binary);
if (err)
return err;
err = devlink_fmsg_pair_nest_start(fmsg, "test_nest"); devlink_fmsg_pair_nest_start(fmsg, "test_nest");
if (err) devlink_fmsg_obj_nest_start(fmsg);
return err; devlink_fmsg_bool_pair_put(fmsg, "nested_test_bool", false);
err = devlink_fmsg_obj_nest_start(fmsg); devlink_fmsg_u8_pair_put(fmsg, "nested_test_u8", false);
if (err) devlink_fmsg_obj_nest_end(fmsg);
return err; devlink_fmsg_pair_nest_end(fmsg);
err = devlink_fmsg_bool_pair_put(fmsg, "nested_test_bool", false); devlink_fmsg_arr_pair_nest_end(fmsg);
if (err) devlink_fmsg_arr_pair_nest_start(fmsg, "test_u32_array");
return err;
err = devlink_fmsg_u8_pair_put(fmsg, "nested_test_u8", false);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_end(fmsg); for (i = 0; i < 10; i++)
if (err) devlink_fmsg_u32_put(fmsg, i);
return err; devlink_fmsg_arr_pair_nest_end(fmsg);
devlink_fmsg_arr_pair_nest_start(fmsg, "test_array_of_objects");
err = devlink_fmsg_arr_pair_nest_start(fmsg, "test_u32_array");
if (err)
return err;
for (i = 0; i < 10; i++) { for (i = 0; i < 10; i++) {
err = devlink_fmsg_u32_put(fmsg, i); devlink_fmsg_obj_nest_start(fmsg);
if (err) devlink_fmsg_bool_pair_put(fmsg, "in_array_nested_test_bool",
return err; false);
devlink_fmsg_u8_pair_put(fmsg, "in_array_nested_test_u8", i);
devlink_fmsg_obj_nest_end(fmsg);
} }
err = devlink_fmsg_arr_pair_nest_end(fmsg); devlink_fmsg_arr_pair_nest_end(fmsg);
if (err)
return err;
err = devlink_fmsg_arr_pair_nest_start(fmsg, "test_array_of_objects"); return 0;
if (err)
return err;
for (i = 0; i < 10; i++) {
err = devlink_fmsg_obj_nest_start(fmsg);
if (err)
return err;
err = devlink_fmsg_bool_pair_put(fmsg,
"in_array_nested_test_bool",
false);
if (err)
return err;
err = devlink_fmsg_u8_pair_put(fmsg,
"in_array_nested_test_u8",
i);
if (err)
return err;
err = devlink_fmsg_obj_nest_end(fmsg);
if (err)
return err;
}
return devlink_fmsg_arr_pair_nest_end(fmsg);
} }
static int static int
...@@ -157,14 +111,10 @@ nsim_dev_dummy_reporter_dump(struct devlink_health_reporter *reporter, ...@@ -157,14 +111,10 @@ nsim_dev_dummy_reporter_dump(struct devlink_health_reporter *reporter,
{ {
struct nsim_dev_health *health = devlink_health_reporter_priv(reporter); struct nsim_dev_health *health = devlink_health_reporter_priv(reporter);
struct nsim_dev_dummy_reporter_ctx *ctx = priv_ctx; struct nsim_dev_dummy_reporter_ctx *ctx = priv_ctx;
int err;
if (ctx) { if (ctx)
err = devlink_fmsg_string_pair_put(fmsg, "break_message", devlink_fmsg_string_pair_put(fmsg, "break_message", ctx->break_msg);
ctx->break_msg);
if (err)
return err;
}
return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len); return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len);
} }
...@@ -174,15 +124,11 @@ nsim_dev_dummy_reporter_diagnose(struct devlink_health_reporter *reporter, ...@@ -174,15 +124,11 @@ nsim_dev_dummy_reporter_diagnose(struct devlink_health_reporter *reporter,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct nsim_dev_health *health = devlink_health_reporter_priv(reporter); struct nsim_dev_health *health = devlink_health_reporter_priv(reporter);
int err;
if (health->recovered_break_msg) { if (health->recovered_break_msg)
err = devlink_fmsg_string_pair_put(fmsg, devlink_fmsg_string_pair_put(fmsg, "recovered_break_message",
"recovered_break_message", health->recovered_break_msg);
health->recovered_break_msg);
if (err)
return err;
}
return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len); return nsim_dev_dummy_fmsg_put(fmsg, health->binary_len);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment