On Tue, Oct 09, 2018 at 07:57:27PM -0700, Andrey Smirnov wrote: > On Tue, Oct 9, 2018 at 10:38 AM Andrey Smirnov <andrew.smirnov@xxxxxxxxx> wrote: > > diff --git a/drivers/base/driver.c b/drivers/base/driver.c > > index c43a4bde2..c25498bf4 100644 > > --- a/drivers/base/driver.c > > +++ b/drivers/base/driver.c > > @@ -468,16 +468,57 @@ EXPORT_SYMBOL(dummy_probe); > > > > const char *dev_id(const struct device_d *dev) > > { > > - static char buf[MAX_DRIVER_NAME + 16]; > > + static char *buf; > > + int err; > > + > > + if (buf) > > + free(buf); > > Ugh, I just realized that original implementation of this function > didn't work right for constructs like > > https://git.pengutronix.de/cgit/barebox/tree/drivers/mci/mci-core.c#n1826 > > because the result of calling dev_name() for one of the arguments > would get clobbered by the call to dev_name() inside of dev_info(). > Switching to heap allocated memory only makes things worse. > > Sascha, one solution for this that I can see is to just return > dev->name for the case of dev->id == DEVICE_ID_SINGLE and add a > "_name" field to struct device_d that can be lazily filled with device > name + ID string for dev->id != DEVICE_ID_SINGLE and returned as > result. Not sure if "name" and "_name" are good names, but generally I think we can do it that way. Could you split this patch up into two and in the first one just add a dev_set_name function which sprintf() into the string array and converts the users and only in the second patch do the conversion to an allocated dev->name? Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox