Re: one last firmware(9) issue

From: Max Laier <max_at_love2party.net>
Date: Thu, 15 Feb 2007 19:34:53 +0100
On Thursday 15 February 2007 18:43, Luigi Rizzo wrote:
> I have committed the cleanup to firmware(9) discussed earlier
> on this list, see the commit log below. There is a remaining issue
> on which i would like some advice. From the commit log:
>
>     Note also that there is a subtle issue with the implementation of
>     firmware_register(): currently, as in the previous version, we just
>     store a reference to the 'imagename' argument, but we should rather
>     copy it because there is no guarantee that this is a static string.
>
> Now, what do you think is the best way to handle this ? The existing
> code tries not to allocate memory on a firmware_register(), not
> sure if it is on purpose (e.g. to avoid sleeping) or for other
> reasons.  To preserve this, we should use static buffers for the
> image names, and pick a reasonable size for them (128 ? 256 ? 1025 ?).
>
> If on the other hand, we can afford a malloc in firmware_register(),
> i'd move the whole registry to a linked list, to avoid the hard limit
> of 30 slots in the firmware table.
>
> suggestions ?

I say, let the caller deal with it.  After all the caller must ensure that 
the firmware itself stays in memory until they call firmware_unregister, 
why should we jump through all the hoops for the name?

The linked list is another thing.  As I recall, the static array is only 
there due to our lazyness.  It's a lot easier to use a static array and I 
don't forsee us using more than 30 firmware images at a time.  OTOH, it 
would of course be nice to have a more flexible system.  I'm not 100% 
certain what the locking constrains for firmware_register() are.  Usually 
it is called from the mod_event of a firmware module, which in turn is 
called from the linker subsystem.  There might be some locks involved 
that would prevent you from sleeping, but that's just a wild guess.

Thanks for taking care of this, by the way.  Much appreciated.

-- 
/"\  Best regards,                      | mlaier_at_freebsd.org
\ /  Max Laier                          | ICQ #67774661
 X   http://pf4freebsd.love2party.net/  | mlaier_at_EFnet
/ \  ASCII Ribbon Campaign              | Against HTML Mail and News

Received on Thu Feb 15 2007 - 17:35:05 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:05 UTC