On Thu, Aug 12, 2021 at 10:14:25AM +0200, Uwe Kleine-K??nig wrote:
dev_driver_string() might return "" (via dev_bus_name()). If that happens
*drvstr == '\0' becomes true.
Would the following be better?:
const char *drvstr;
if (pdev)
return "<null>";
drvstr = dev_driver_string(&pdev->dev);
if (!strcmp(drvstr, ""))
return "<null>";
return drvstr;
When I thought about this hunk I considered it ugly to have "<null>" in
it twice.
Well, if you want to avoid that you can do:
if (pdev) {
const char *name = dev_driver_string(&pdev->dev);
if (strcmp(drvstr, ""))
return name;
}
return "<null>";
Which would be a lot more readable.