linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Some function locals in udev_rules_parse.c were needlessly
@ 2008-08-31 17:30 Alan Jenkins
  2008-09-01 14:32 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly declared as static Kay Sievers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alan Jenkins @ 2008-08-31 17:30 UTC (permalink / raw)
  To: linux-hotplug

This does not affect current behaviour.  However, it is required to
make the functions thread-safe.  (I'm playing with a threaded udevd).

Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>

diff --git a/udev/udev_rules_parse.c b/udev/udev_rules_parse.c
index 705b3fe..90b139b 100644
--- a/udev/udev_rules_parse.c
+++ b/udev/udev_rules_parse.c
@@ -41,7 +41,7 @@ void udev_rules_iter_init(struct udev_rules *rules)
 
 struct udev_rule *udev_rules_iter_next(struct udev_rules *rules)
 {
-	static struct udev_rule *rule;
+	struct udev_rule *rule;
 
 	if (!rules)
 		return NULL;
@@ -61,7 +61,7 @@ struct udev_rule *udev_rules_iter_next(struct udev_rules *rules)
 
 struct udev_rule *udev_rules_iter_label(struct udev_rules *rules, const char *label)
 {
-	static struct udev_rule *rule;
+	struct udev_rule *rule;
 	size_t start = rules->current;
 
 next:



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Some function locals in udev_rules_parse.c were needlessly declared as static
  2008-08-31 17:30 [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
@ 2008-09-01 14:32 ` Kay Sievers
  2008-09-01 17:37 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
  2008-09-01 17:50 ` [PATCH] Some function locals in udev_rules_parse.c were Kay Sievers
  2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2008-09-01 14:32 UTC (permalink / raw)
  To: linux-hotplug

On Sun, Aug 31, 2008 at 19:30, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
> This does not affect current behaviour.  However, it is required to
> make the functions thread-safe.  (I'm playing with a threaded udevd).

> -       static struct udev_rule *rule;
> +       struct udev_rule *rule;

It's not needlessly static, we return _this_ value. The parsing stuff
is not thread safe at the moment, we would need a real fix, this would
break it.

Thanks,
Kay

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Some function locals in udev_rules_parse.c were needlessly
  2008-08-31 17:30 [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
  2008-09-01 14:32 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly declared as static Kay Sievers
@ 2008-09-01 17:37 ` Alan Jenkins
  2008-09-01 17:50 ` [PATCH] Some function locals in udev_rules_parse.c were Kay Sievers
  2 siblings, 0 replies; 4+ messages in thread
From: Alan Jenkins @ 2008-09-01 17:37 UTC (permalink / raw)
  To: linux-hotplug

Kay Sievers wrote:
> On Sun, Aug 31, 2008 at 19:30, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
>   
>> This does not affect current behaviour.  However, it is required to
>> make the functions thread-safe.  (I'm playing with a threaded udevd).
>>     
>
>   
>> -       static struct udev_rule *rule;
>> +       struct udev_rule *rule;
>>     
>
> It's not needlessly static, we return _this_ value. The parsing stuff
> is not thread safe at the moment, we would need a real fix, this would
> break it.
>   
Thanks for looking at these patches.

The functions do "return rule", but they always write to it before
reading it, so there's no persistent state here.  And they don't "return
&rule", so it's fine for the variable to be on the stack.  Did I miss
something?

I belatedly noticed the other parsing stuff a few hours after posting
the patch :-).  I hacked it up and (with unpublished patches) finally
got a threaded udevd which appeared to work.  (I also did per-thread
environment variable emulation, and fixed the caches in udev_sysfs.c for
thread-safety).  So empirically I had judged this patch correct.  And my
unpublished patches wouldn't conflict with or obsolete this one.

Regards
Alan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Some function locals in udev_rules_parse.c were
  2008-08-31 17:30 [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
  2008-09-01 14:32 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly declared as static Kay Sievers
  2008-09-01 17:37 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
@ 2008-09-01 17:50 ` Kay Sievers
  2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2008-09-01 17:50 UTC (permalink / raw)
  To: linux-hotplug

On Mon, 2008-09-01 at 18:37 +0100, Alan Jenkins wrote:
> Kay Sievers wrote:
> > On Sun, Aug 31, 2008 at 19:30, Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
> >   
> >> This does not affect current behaviour.  However, it is required to
> >> make the functions thread-safe.  (I'm playing with a threaded udevd).
> >>     
> >
> >   
> >> -       static struct udev_rule *rule;
> >> +       struct udev_rule *rule;
> >>     
> >
> > It's not needlessly static, we return _this_ value. The parsing stuff
> > is not thread safe at the moment, we would need a real fix, this would
> > break it.
> >   
> Thanks for looking at these patches.
> 
> The functions do "return rule", but they always write to it before
> reading it, so there's no persistent state here.  And they don't "return
> &rule", so it's fine for the variable to be on the stack.  Did I miss
> something?

Ah, they should return a pointer to the data passed in to the function,
which should be fine.

Applied.

Thanks,
Kay


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-09-01 17:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-31 17:30 [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
2008-09-01 14:32 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly declared as static Kay Sievers
2008-09-01 17:37 ` [PATCH] Some function locals in udev_rules_parse.c were needlessly Alan Jenkins
2008-09-01 17:50 ` [PATCH] Some function locals in udev_rules_parse.c were Kay Sievers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).