List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH 0/2] Compatibility fixes for non-Linux platforms
@ 2011-07-22 15:15 cgit
  2011-07-22 15:15 ` [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include cgit
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: cgit @ 2011-07-22 15:15 UTC (permalink / raw)


From: Lukas Fleischer <info at cryptocrack.de>

I just spotted these when trying to compile current master on OpenBSD.
Trivial to fix.

The stable branch doesn't seem to be affected as it doesn't contain any
of Ferry's and Lars's cgit_open_filter() changes.

Lukas Fleischer (2):
  shared.c: Remove unused "linux/limits.h" include
  shared.c: Only setenv() if value is non-null

 shared.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

-- 
1.7.6





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

* [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include
  2011-07-22 15:15 [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
@ 2011-07-22 15:15 ` cgit
  2012-01-03 15:04   ` hjemli
  2011-07-22 15:15 ` [PATCH 2/2] shared.c: Only setenv() if value is non-null cgit
  2011-07-22 15:19 ` [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
  2 siblings, 1 reply; 16+ messages in thread
From: cgit @ 2011-07-22 15:15 UTC (permalink / raw)


This isn't used anywhere and prevents the code from being compiled on
other platforms, such as *BSD.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
 shared.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/shared.c b/shared.c
index 699c362..75c4b5c 100644
--- a/shared.c
+++ b/shared.c
@@ -8,7 +8,6 @@
 
 #include "cgit.h"
 #include <stdio.h>
-#include <linux/limits.h>
 
 struct cgit_repolist cgit_repolist;
 struct cgit_context ctx;
-- 
1.7.6





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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-22 15:15 [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
  2011-07-22 15:15 ` [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include cgit
@ 2011-07-22 15:15 ` cgit
  2011-07-26 11:18   ` mailings
  2011-09-14  9:52   ` [PATCH] " cgit
  2011-07-22 15:19 ` [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
  2 siblings, 2 replies; 16+ messages in thread
From: cgit @ 2011-07-22 15:15 UTC (permalink / raw)


Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
segfault if we pass a NULL value. Add an additional check to avoid this.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
 shared.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/shared.c b/shared.c
index 75c4b5c..0c8ce3e 100644
--- a/shared.c
+++ b/shared.c
@@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
 	p = env_vars;
 	q = p + env_var_count;
 	for (; p < q; p++)
-		if (setenv(p->name, p->value, 1))
+		if (p->value && setenv(p->name, p->value, 1))
 			fprintf(stderr, warn, p->name, p->value);
 }
 
-- 
1.7.6





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

* [PATCH 0/2] Compatibility fixes for non-Linux platforms
  2011-07-22 15:15 [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
  2011-07-22 15:15 ` [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include cgit
  2011-07-22 15:15 ` [PATCH 2/2] shared.c: Only setenv() if value is non-null cgit
@ 2011-07-22 15:19 ` cgit
  2 siblings, 0 replies; 16+ messages in thread
From: cgit @ 2011-07-22 15:19 UTC (permalink / raw)


On Fri, Jul 22, 2011 at 05:15:48PM +0200, Lukas Fleischer wrote:
> From: Lukas Fleischer <info at cryptocrack.de>

That happens if your main development box is down and you forgot to
setup Git properly on the second system *sigh*

Just ignore that...

> 
> I just spotted these when trying to compile current master on OpenBSD.
> Trivial to fix.
> 
> The stable branch doesn't seem to be affected as it doesn't contain any
> of Ferry's and Lars's cgit_open_filter() changes.
> 
> Lukas Fleischer (2):
>   shared.c: Remove unused "linux/limits.h" include
>   shared.c: Only setenv() if value is non-null
> 
>  shared.c |    3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> -- 
> 1.7.6




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-22 15:15 ` [PATCH 2/2] shared.c: Only setenv() if value is non-null cgit
@ 2011-07-26 11:18   ` mailings
  2011-07-26 13:32     ` cgit
  2011-09-14  9:52   ` [PATCH] " cgit
  1 sibling, 1 reply; 16+ messages in thread
From: mailings @ 2011-07-26 11:18 UTC (permalink / raw)


On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
> segfault if we pass a NULL value. Add an additional check to avoid this.
> 
> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> ---
>  shared.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/shared.c b/shared.c
> index 75c4b5c..0c8ce3e 100644
> --- a/shared.c
> +++ b/shared.c
> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
>  	p = env_vars;
>  	q = p + env_var_count;
>  	for (; p < q; p++)
> -		if (setenv(p->name, p->value, 1))
> +		if (p->value && setenv(p->name, p->value, 1))
>  			fprintf(stderr, warn, p->name, p->value);
>  }
>  

Lukas,

I don't agree with this patch.
From cgitrc.5.txt, lines 501-503:

> If a setting is not defined for a repository and the corresponding global
> setting is also not defined (if applicable), then the corresponding
> environment variable will be an empty string.

So I'd like this differently, an empty string must be set.



-- 
Ferry Huberts




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 11:18   ` mailings
@ 2011-07-26 13:32     ` cgit
  2011-07-26 14:24       ` mailings
  0 siblings, 1 reply; 16+ messages in thread
From: cgit @ 2011-07-26 13:32 UTC (permalink / raw)


On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
> > Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
> > segfault if we pass a NULL value. Add an additional check to avoid this.
> > 
> > Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> > ---
> >  shared.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/shared.c b/shared.c
> > index 75c4b5c..0c8ce3e 100644
> > --- a/shared.c
> > +++ b/shared.c
> > @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
> >  	p = env_vars;
> >  	q = p + env_var_count;
> >  	for (; p < q; p++)
> > -		if (setenv(p->name, p->value, 1))
> > +		if (p->value && setenv(p->name, p->value, 1))
> >  			fprintf(stderr, warn, p->name, p->value);
> >  }
> >  
> 
> Lukas,
> 
> I don't agree with this patch.
> >From cgitrc.5.txt, lines 501-503:
> 
> > If a setting is not defined for a repository and the corresponding global
> > setting is also not defined (if applicable), then the corresponding
> > environment variable will be an empty string.
> 
> So I'd like this differently, an empty string must be set.

-1. Is there any reason to do this? Imho, we should leave undefined
variables unset and fix the documentation here. This is way more
straightforward and allows for distinguishing between unset and empty
values (this is cleaner, even though there might not be a use case yet).

Objections?




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 13:32     ` cgit
@ 2011-07-26 14:24       ` mailings
  2011-07-26 14:48         ` cgit
  0 siblings, 1 reply; 16+ messages in thread
From: mailings @ 2011-07-26 14:24 UTC (permalink / raw)


On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
> On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
>> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
>>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
>>> segfault if we pass a NULL value. Add an additional check to avoid this.
>>>
>>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
>>> ---
>>>  shared.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>
>>> diff --git a/shared.c b/shared.c
>>> index 75c4b5c..0c8ce3e 100644
>>> --- a/shared.c
>>> +++ b/shared.c
>>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
>>>  	p = env_vars;
>>>  	q = p + env_var_count;
>>>  	for (; p < q; p++)
>>> -		if (setenv(p->name, p->value, 1))
>>> +		if (p->value && setenv(p->name, p->value, 1))
>>>  			fprintf(stderr, warn, p->name, p->value);
>>>  }
>>>  
>>
>> Lukas,
>>
>> I don't agree with this patch.
>> >From cgitrc.5.txt, lines 501-503:
>>
>>> If a setting is not defined for a repository and the corresponding global
>>> setting is also not defined (if applicable), then the corresponding
>>> environment variable will be an empty string.
>>
>> So I'd like this differently, an empty string must be set.
> 
> -1. Is there any reason to do this? Imho, we should leave undefined
> variables unset and fix the documentation here. This is way more
> straightforward and allows for distinguishing between unset and empty
> values (this is cleaner, even though there might not be a use case yet).

Not true, I run this code on my servers.

I agree with the fact that it is cleaner but am reluctant to have this
change.

I can live with that but let's ask Lars what he thinks about this




-- 
Ferry Huberts




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 14:24       ` mailings
@ 2011-07-26 14:48         ` cgit
  2011-07-26 16:15           ` mailings
  0 siblings, 1 reply; 16+ messages in thread
From: cgit @ 2011-07-26 14:48 UTC (permalink / raw)


On Tue, Jul 26, 2011 at 04:24:14PM +0200, Ferry Huberts wrote:
> On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
> > On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
> >> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
> >>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
> >>> segfault if we pass a NULL value. Add an additional check to avoid this.
> >>>
> >>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> >>> ---
> >>>  shared.c |    2 +-
> >>>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>>
> >>> diff --git a/shared.c b/shared.c
> >>> index 75c4b5c..0c8ce3e 100644
> >>> --- a/shared.c
> >>> +++ b/shared.c
> >>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
> >>>  	p = env_vars;
> >>>  	q = p + env_var_count;
> >>>  	for (; p < q; p++)
> >>> -		if (setenv(p->name, p->value, 1))
> >>> +		if (p->value && setenv(p->name, p->value, 1))
> >>>  			fprintf(stderr, warn, p->name, p->value);
> >>>  }
> >>>  
> >>
> >> Lukas,
> >>
> >> I don't agree with this patch.
> >> >From cgitrc.5.txt, lines 501-503:
> >>
> >>> If a setting is not defined for a repository and the corresponding global
> >>> setting is also not defined (if applicable), then the corresponding
> >>> environment variable will be an empty string.
> >>
> >> So I'd like this differently, an empty string must be set.
> > 
> > -1. Is there any reason to do this? Imho, we should leave undefined
> > variables unset and fix the documentation here. This is way more
> > straightforward and allows for distinguishing between unset and empty
> > values (this is cleaner, even though there might not be a use case yet).
> 
> Not true, I run this code on my servers.
> 
> I agree with the fact that it is cleaner but am reluctant to have this
> change.

Wait, do you actually depend on having these environment variables
defined? Leaving environment variables unset instead of initializing
them to an empty string shouldn't make any difference if you use a shell
script (unless you check for it explicitly or do some fancy stuff).

If you use C (other any other programming language that uses getenv() or
behaves similarly), making your code compatible is as easy as modifying
the NULL check branch after getenv() to set the result to an empty
string instead of bailing out. It literally is a one-line diff.

Given that this is a real improvement and we only break backwards
compatibility for a few corner cases, +1 to changing this here.

> 
> I can live with that but let's ask Lars what he thinks about this

Ack.




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 14:48         ` cgit
@ 2011-07-26 16:15           ` mailings
  2011-07-26 16:39             ` cgit
  0 siblings, 1 reply; 16+ messages in thread
From: mailings @ 2011-07-26 16:15 UTC (permalink / raw)


On 07/26/2011 04:48 PM, Lukas Fleischer wrote:
> On Tue, Jul 26, 2011 at 04:24:14PM +0200, Ferry Huberts wrote:
>> On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
>>> On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
>>>> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
>>>>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
>>>>> segfault if we pass a NULL value. Add an additional check to avoid this.
>>>>>
>>>>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
>>>>> ---
>>>>>  shared.c |    2 +-
>>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>
>>>>> diff --git a/shared.c b/shared.c
>>>>> index 75c4b5c..0c8ce3e 100644
>>>>> --- a/shared.c
>>>>> +++ b/shared.c
>>>>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
>>>>>  	p = env_vars;
>>>>>  	q = p + env_var_count;
>>>>>  	for (; p < q; p++)
>>>>> -		if (setenv(p->name, p->value, 1))
>>>>> +		if (p->value && setenv(p->name, p->value, 1))
>>>>>  			fprintf(stderr, warn, p->name, p->value);
>>>>>  }
>>>>>  
>>>>
>>>> Lukas,
>>>>
>>>> I don't agree with this patch.
>>>> >From cgitrc.5.txt, lines 501-503:
>>>>
>>>>> If a setting is not defined for a repository and the corresponding global
>>>>> setting is also not defined (if applicable), then the corresponding
>>>>> environment variable will be an empty string.
>>>>
>>>> So I'd like this differently, an empty string must be set.
>>>
>>> -1. Is there any reason to do this? Imho, we should leave undefined
>>> variables unset and fix the documentation here. This is way more
>>> straightforward and allows for distinguishing between unset and empty
>>> values (this is cleaner, even though there might not be a use case yet).
>>
>> Not true, I run this code on my servers.
>>
>> I agree with the fact that it is cleaner but am reluctant to have this
>> change.
> 
> Wait, do you actually depend on having these environment variables
> defined? Leaving environment variables unset instead of initializing
> them to an empty string shouldn't make any difference if you use a shell
> script (unless you check for it explicitly or do some fancy stuff).
> 

unless you use 'set -u', which I do.

> If you use C (other any other programming language that uses getenv() or
> behaves similarly), making your code compatible is as easy as modifying
> the NULL check branch after getenv() to set the result to an empty
> string instead of bailing out. It literally is a one-line diff.
> 
> Given that this is a real improvement and we only break backwards
> compatibility for a few corner cases, +1 to changing this here.

From my point of view it is an ABI change...

Granted, there don't seem to be many users of this yet but an ABI change
nonetheless



-- 
Ferry Huberts




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 16:15           ` mailings
@ 2011-07-26 16:39             ` cgit
  2011-09-14  7:09               ` hjemli
  0 siblings, 1 reply; 16+ messages in thread
From: cgit @ 2011-07-26 16:39 UTC (permalink / raw)


On Tue, Jul 26, 2011 at 06:15:07PM +0200, Ferry Huberts wrote:
> On 07/26/2011 04:48 PM, Lukas Fleischer wrote:
> > On Tue, Jul 26, 2011 at 04:24:14PM +0200, Ferry Huberts wrote:
> >> On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
> >>> On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
> >>>> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
> >>>>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
> >>>>> segfault if we pass a NULL value. Add an additional check to avoid this.
> >>>>>
> >>>>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
> >>>>> ---
> >>>>>  shared.c |    2 +-
> >>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
> >>>>>
> >>>>> diff --git a/shared.c b/shared.c
> >>>>> index 75c4b5c..0c8ce3e 100644
> >>>>> --- a/shared.c
> >>>>> +++ b/shared.c
> >>>>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
> >>>>>  	p = env_vars;
> >>>>>  	q = p + env_var_count;
> >>>>>  	for (; p < q; p++)
> >>>>> -		if (setenv(p->name, p->value, 1))
> >>>>> +		if (p->value && setenv(p->name, p->value, 1))
> >>>>>  			fprintf(stderr, warn, p->name, p->value);
> >>>>>  }
> >>>>>  
> >>>>
> >>>> Lukas,
> >>>>
> >>>> I don't agree with this patch.
> >>>> >From cgitrc.5.txt, lines 501-503:
> >>>>
> >>>>> If a setting is not defined for a repository and the corresponding global
> >>>>> setting is also not defined (if applicable), then the corresponding
> >>>>> environment variable will be an empty string.
> >>>>
> >>>> So I'd like this differently, an empty string must be set.
> >>>
> >>> -1. Is there any reason to do this? Imho, we should leave undefined
> >>> variables unset and fix the documentation here. This is way more
> >>> straightforward and allows for distinguishing between unset and empty
> >>> values (this is cleaner, even though there might not be a use case yet).
> >>
> >> Not true, I run this code on my servers.
> >>
> >> I agree with the fact that it is cleaner but am reluctant to have this
> >> change.
> > 
> > Wait, do you actually depend on having these environment variables
> > defined? Leaving environment variables unset instead of initializing
> > them to an empty string shouldn't make any difference if you use a shell
> > script (unless you check for it explicitly or do some fancy stuff).
> > 
> 
> unless you use 'set -u', which I do.

In that case just use "${CGIT_*-}" or do some manual checking. Easy
enough to fix.

> > If you use C (other any other programming language that uses getenv() or
> > behaves similarly), making your code compatible is as easy as modifying
> > the NULL check branch after getenv() to set the result to an empty
> > string instead of bailing out. It literally is a one-line diff.
> > 
> > Given that this is a real improvement and we only break backwards
> > compatibility for a few corner cases, +1 to changing this here.
> 
> >From my point of view it is an ABI change...
> 
> Granted, there don't seem to be many users of this yet but an ABI change
> nonetheless

It is a minor ABI change, yeah. Well, let's let Lars decide. If he says
we're not gonna change this now, I'll send an amended patch.




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-07-26 16:39             ` cgit
@ 2011-09-14  7:09               ` hjemli
  2011-09-14  7:37                 ` mailings
  0 siblings, 1 reply; 16+ messages in thread
From: hjemli @ 2011-09-14  7:09 UTC (permalink / raw)


[My apologies for the extremly late reply]

On Tue, Jul 26, 2011 at 18:39, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> On Tue, Jul 26, 2011 at 06:15:07PM +0200, Ferry Huberts wrote:
>> On 07/26/2011 04:48 PM, Lukas Fleischer wrote:
>> > On Tue, Jul 26, 2011 at 04:24:14PM +0200, Ferry Huberts wrote:
>> >> On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
>> >>> On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
>> >>>> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
>> >>>>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
>> >>>>> segfault if we pass a NULL value. Add an additional check to avoid this.
>> >>>>>
>> >>>>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
>> >>>>> ---
>> >>>>> ?shared.c | ? ?2 +-
>> >>>>> ?1 files changed, 1 insertions(+), 1 deletions(-)
>> >>>>>
>> >>>>> diff --git a/shared.c b/shared.c
>> >>>>> index 75c4b5c..0c8ce3e 100644
>> >>>>> --- a/shared.c
>> >>>>> +++ b/shared.c
>> >>>>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
>> >>>>> ? ? ? ? p = env_vars;
>> >>>>> ? ? ? ? q = p + env_var_count;
>> >>>>> ? ? ? ? for (; p < q; p++)
>> >>>>> - ? ? ? ? ? ? ? if (setenv(p->name, p->value, 1))
>> >>>>> + ? ? ? ? ? ? ? if (p->value && setenv(p->name, p->value, 1))
>> >>>>> ? ? ? ? ? ? ? ? ? ? ? ? fprintf(stderr, warn, p->name, p->value);
>> >>>>> ?}
>> >>>>>
>> >>>>
>> >>>> Lukas,
>> >>>>
>> >>>> I don't agree with this patch.
>> >>>> >From cgitrc.5.txt, lines 501-503:
>> >>>>
>> >>>>> If a setting is not defined for a repository and the corresponding global
>> >>>>> setting is also not defined (if applicable), then the corresponding
>> >>>>> environment variable will be an empty string.
>> >>>>
>> >>>> So I'd like this differently, an empty string must be set.
>> >>>
>> >>> -1. Is there any reason to do this? Imho, we should leave undefined
>> >>> variables unset and fix the documentation here. This is way more
>> >>> straightforward and allows for distinguishing between unset and empty
>> >>> values (this is cleaner, even though there might not be a use case yet).
>> >>
>> >> Not true, I run this code on my servers.
>> >>
>> >> I agree with the fact that it is cleaner but am reluctant to have this
>> >> change.
>> >
>> > Wait, do you actually depend on having these environment variables
>> > defined? Leaving environment variables unset instead of initializing
>> > them to an empty string shouldn't make any difference if you use a shell
>> > script (unless you check for it explicitly or do some fancy stuff).
>> >
>>
>> unless you use 'set -u', which I do.
>
> In that case just use "${CGIT_*-}" or do some manual checking. Easy
> enough to fix.
>
>> > If you use C (other any other programming language that uses getenv() or
>> > behaves similarly), making your code compatible is as easy as modifying
>> > the NULL check branch after getenv() to set the result to an empty
>> > string instead of bailing out. It literally is a one-line diff.
>> >
>> > Given that this is a real improvement and we only break backwards
>> > compatibility for a few corner cases, +1 to changing this here.
>>
>> >From my point of view it is an ABI change...
>>
>> Granted, there don't seem to be many users of this yet but an ABI change
>> nonetheless
>
> It is a minor ABI change, yeah. Well, let's let Lars decide. If he says
> we're not gonna change this now, I'll send an amended patch.
>

Since the feature which this patch fixes hasn't been included in any
released version yet, I don't think the ABI-argument is very important
(no disrespect intended). So, we're free to tweak the feature into
perfection and I think Lukas' patch is a nice step in that direction.
But cgitrc.5 also needs updating...

-- 
larsh




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

* [PATCH 2/2] shared.c: Only setenv() if value is non-null
  2011-09-14  7:09               ` hjemli
@ 2011-09-14  7:37                 ` mailings
  0 siblings, 0 replies; 16+ messages in thread
From: mailings @ 2011-09-14  7:37 UTC (permalink / raw)


On 09/14/2011 09:09 AM, Lars Hjemli wrote:
> [My apologies for the extremly late reply]
> 
> On Tue, Jul 26, 2011 at 18:39, Lukas Fleischer <cgit at cryptocrack.de> wrote:
>> On Tue, Jul 26, 2011 at 06:15:07PM +0200, Ferry Huberts wrote:
>>> On 07/26/2011 04:48 PM, Lukas Fleischer wrote:
>>>> On Tue, Jul 26, 2011 at 04:24:14PM +0200, Ferry Huberts wrote:
>>>>> On 07/26/2011 03:32 PM, Lukas Fleischer wrote:
>>>>>> On Tue, Jul 26, 2011 at 01:18:14PM +0200, Ferry Huberts wrote:
>>>>>>> On 07/22/2011 05:15 PM, Lukas Fleischer wrote:
>>>>>>>> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
>>>>>>>> segfault if we pass a NULL value. Add an additional check to avoid this.
>>>>>>>>
>>>>>>>> Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
>>>>>>>> ---
>>>>>>>>  shared.c |    2 +-
>>>>>>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>>>>>>>
>>>>>>>> diff --git a/shared.c b/shared.c
>>>>>>>> index 75c4b5c..0c8ce3e 100644
>>>>>>>> --- a/shared.c
>>>>>>>> +++ b/shared.c
>>>>>>>> @@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
>>>>>>>>         p = env_vars;
>>>>>>>>         q = p + env_var_count;
>>>>>>>>         for (; p < q; p++)
>>>>>>>> -               if (setenv(p->name, p->value, 1))
>>>>>>>> +               if (p->value && setenv(p->name, p->value, 1))
>>>>>>>>                         fprintf(stderr, warn, p->name, p->value);
>>>>>>>>  }
>>>>>>>>
>>>>>>>
>>>>>>> Lukas,
>>>>>>>
>>>>>>> I don't agree with this patch.
>>>>>>> >From cgitrc.5.txt, lines 501-503:
>>>>>>>
>>>>>>>> If a setting is not defined for a repository and the corresponding global
>>>>>>>> setting is also not defined (if applicable), then the corresponding
>>>>>>>> environment variable will be an empty string.
>>>>>>>
>>>>>>> So I'd like this differently, an empty string must be set.
>>>>>>
>>>>>> -1. Is there any reason to do this? Imho, we should leave undefined
>>>>>> variables unset and fix the documentation here. This is way more
>>>>>> straightforward and allows for distinguishing between unset and empty
>>>>>> values (this is cleaner, even though there might not be a use case yet).
>>>>>
>>>>> Not true, I run this code on my servers.
>>>>>
>>>>> I agree with the fact that it is cleaner but am reluctant to have this
>>>>> change.
>>>>
>>>> Wait, do you actually depend on having these environment variables
>>>> defined? Leaving environment variables unset instead of initializing
>>>> them to an empty string shouldn't make any difference if you use a shell
>>>> script (unless you check for it explicitly or do some fancy stuff).
>>>>
>>>
>>> unless you use 'set -u', which I do.
>>
>> In that case just use "${CGIT_*-}" or do some manual checking. Easy
>> enough to fix.
>>
>>>> If you use C (other any other programming language that uses getenv() or
>>>> behaves similarly), making your code compatible is as easy as modifying
>>>> the NULL check branch after getenv() to set the result to an empty
>>>> string instead of bailing out. It literally is a one-line diff.
>>>>
>>>> Given that this is a real improvement and we only break backwards
>>>> compatibility for a few corner cases, +1 to changing this here.
>>>
>>> >From my point of view it is an ABI change...
>>>
>>> Granted, there don't seem to be many users of this yet but an ABI change
>>> nonetheless
>>
>> It is a minor ABI change, yeah. Well, let's let Lars decide. If he says
>> we're not gonna change this now, I'll send an amended patch.
>>
> 
> Since the feature which this patch fixes hasn't been included in any
> released version yet, I don't think the ABI-argument is very important
> (no disrespect intended). So, we're free to tweak the feature into
> perfection and I think Lukas' patch is a nice step in that direction.
> But cgitrc.5 also needs updating...
> 

I already anticipated your reply and updated my server scripting :-)

I'll let Lukas send in a patch updating the documentation (don't forget
the example scripts) ;-)

-- 
Ferry Huberts




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

* [PATCH] shared.c: Only setenv() if value is non-null
  2011-07-22 15:15 ` [PATCH 2/2] shared.c: Only setenv() if value is non-null cgit
  2011-07-26 11:18   ` mailings
@ 2011-09-14  9:52   ` cgit
  2012-01-03 15:06     ` hjemli
  1 sibling, 1 reply; 16+ messages in thread
From: cgit @ 2011-09-14  9:52 UTC (permalink / raw)


Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
segfault if we pass a NULL value. Only set environment variables if the
corresponding settings are defined to avoid this.

Note that this is a minor behaviour change as environment variables were
supposed to be set to an empty string if a setting was undefined. Given
that this feature isn't part of any official release yet, there's no
need to worry about backwards compatibility, really. Change the
documentation accordingly.

Signed-off-by: Lukas Fleischer <cgit at cryptocrack.de>
---
 cgitrc.5.txt |    2 +-
 shared.c     |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 4721c1e..a22423b 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -500,7 +500,7 @@ Also, all filters are handed the following environment variables:
 
 If a setting is not defined for a repository and the corresponding global
 setting is also not defined (if applicable), then the corresponding
-environment variable will be an empty string.
+environment variable will be unset.
 
 
 MACRO EXPANSION
diff --git a/shared.c b/shared.c
index 75c4b5c..0c8ce3e 100644
--- a/shared.c
+++ b/shared.c
@@ -392,7 +392,7 @@ void cgit_prepare_repo_env(struct cgit_repo * repo)
 	p = env_vars;
 	q = p + env_var_count;
 	for (; p < q; p++)
-		if (setenv(p->name, p->value, 1))
+		if (p->value && setenv(p->name, p->value, 1))
 			fprintf(stderr, warn, p->name, p->value);
 }
 
-- 
1.7.6.1





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

* [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include
  2011-07-22 15:15 ` [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include cgit
@ 2012-01-03 15:04   ` hjemli
  0 siblings, 0 replies; 16+ messages in thread
From: hjemli @ 2012-01-03 15:04 UTC (permalink / raw)


On Fri, Jul 22, 2011 at 17:15, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> This isn't used anywhere and prevents the code from being compiled on
> other platforms, such as *BSD.

Thanks, this has finally been applied.

--
larsh




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

* [PATCH] shared.c: Only setenv() if value is non-null
  2011-09-14  9:52   ` [PATCH] " cgit
@ 2012-01-03 15:06     ` hjemli
  2012-01-03 15:13       ` mailings
  0 siblings, 1 reply; 16+ messages in thread
From: hjemli @ 2012-01-03 15:06 UTC (permalink / raw)


On Wed, Sep 14, 2011 at 11:52, Lukas Fleischer <cgit at cryptocrack.de> wrote:
> Some setenv() implementations (e.g. the one in OpenBSD's stdlib)
> segfault if we pass a NULL value. Only set environment variables if the
> corresponding settings are defined to avoid this.

Thanks, also finally applied.

--
larsh




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

* [PATCH] shared.c: Only setenv() if value is non-null
  2012-01-03 15:06     ` hjemli
@ 2012-01-03 15:13       ` mailings
  0 siblings, 0 replies; 16+ messages in thread
From: mailings @ 2012-01-03 15:13 UTC (permalink / raw)


Lars!

Happy you're back!


Ferry




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

end of thread, other threads:[~2012-01-03 15:13 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-22 15:15 [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit
2011-07-22 15:15 ` [PATCH 1/2] shared.c: Remove unused "linux/limits.h" include cgit
2012-01-03 15:04   ` hjemli
2011-07-22 15:15 ` [PATCH 2/2] shared.c: Only setenv() if value is non-null cgit
2011-07-26 11:18   ` mailings
2011-07-26 13:32     ` cgit
2011-07-26 14:24       ` mailings
2011-07-26 14:48         ` cgit
2011-07-26 16:15           ` mailings
2011-07-26 16:39             ` cgit
2011-09-14  7:09               ` hjemli
2011-09-14  7:37                 ` mailings
2011-09-14  9:52   ` [PATCH] " cgit
2012-01-03 15:06     ` hjemli
2012-01-03 15:13       ` mailings
2011-07-22 15:19 ` [PATCH 0/2] Compatibility fixes for non-Linux platforms cgit

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).