some simplifications in hw/core/fw-path-provider.c
PATCH 1/2 hw/core/fw-path-provider: turn fw_path_provider_get_dev_path() static
In reply to Daniel Henrique BarbozaThis function is used only by fw_path_provider_try_get_dev_path() in the same file.
--- hw/core/fw-path-provider.c | 4 ++-- include/hw/fw-path-provider.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)
hw/core/fw-path-provider.c +2 -2
@@ -19,8 +19,8 @@#include "hw/fw-path-provider.h" #include "qemu/module.h" -char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, -DeviceState *dev) +static char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, +DeviceState *dev) {FWPathProviderClass *k =FW_PATH_PROVIDER_GET_CLASS (p);
include/hw/fw-path-provider.h +0 -2
@@ -36,8 +36,6 @@ struct FWPathProviderClass {char *(*get_dev_path)(FWPathProvider *p,BusState *bus,DeviceState *dev); }; -char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, -DeviceState *dev);char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus,DeviceState *dev);
Signature · 1 line
2.34.1
PATCH 2/2 hw/core/fw-path-provider.c: open code fw_path_provider_get_dev_path()
In reply to Daniel Henrique Barbozafw_path_provider_get_dev_path() is 2 lines long and it's used only by fw_path_provider_try_get_dev_path(), which checks if FWPathProvider is not NULL before calling it.
Open coding fw_path_provider_get_dev_path() into fw_path_provider_try_get_dev_path() simplifies the code inside fw-path-provider.c and make it easier to grep our way into finding the callers of the FWPathProviderClass::get_dev_path() interface.
--- hw/core/fw-path-provider.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-)
hw/core/fw-path-provider.c +3 -11
@@ -19,25 +19,17 @@#include "hw/fw-path-provider.h" #include "qemu/module.h" -static char *fw_path_provider_get_dev_path (FWPathProvider *p,BusState *bus, -DeviceState *dev) -{ -FWPathProviderClass *k =FW_PATH_PROVIDER_GET_CLASS (p); - -return k->get_dev_path (p, bus, dev); -} -char *fw_path_provider_try_get_dev_path (Object *o,BusState *bus,DeviceState *dev) {FWPathProvider *p = (FWPathProvider *)object_dynamic_cast (o,TYPE_FW_PATH_PROVIDER ); -if (p) { -return fw_path_provider_get_dev_path (p, bus, dev); +if (!p) { +return NULL ; } -return NULL ; +return FW_PATH_PROVIDER_GET_CLASS (p)->get_dev_path (p, bus, dev); }static const TypeInfo fw_path_provider_info = {
Signature · 1 line
2.34.1
cover some simplifications in hw/core/fw-path-provider.c
Hi,
These are somes simplifications I found interesting to make while I was investigating Gitlab #720.
It isn't clear in the MAINTAINERS file who is responsible for this file, so I'm ccing the QOM maintainers since it's the closest match.
Daniel Henrique Barboza (2):
hw/core/fw-path-provider: turn fw_path_provider_get_dev_path() static hw/core/fw-path-provider.c: open code fw_path_provider_get_dev_path()
hw/core/fw-path-provider.c | 14 +++----------- include/hw/fw-path-provider.h | 2 -- 2 files changed, 3 insertions(+), 13 deletions(-)
Signature · 1 line
2.34.1
Quoted 5 lines · Daniel Henrique Barboza
Hi,
These are somes simplifications I found interesting to make while I was investigating Gitlab #720.
Quoted 7 lines
It isn't clear in the
MAINTAINERSfile who is responsible for this file, so I'm ccing the QOM maintainers since it's the closest match.Daniel Henrique Barboza (2):
hw/core/fw-path-provider: turnfw_path_provider_get_dev_path()statichw/core/fw-path-provider.c: open codefw_path_provider_get_dev_path()