[FFmpeg-devel] [PATCH] Fix ffserver.c putenv gcc warning

Baptiste Coudurier baptiste.coudurier
Sun Jun 8 01:56:29 CEST 2008


Stefano Sabatini wrote:
> On date Monday 2008-06-02 14:51:53 -0700, Baptiste Coudurier encoded:
>> Hi,
>>
>> Stefano Sabatini wrote:
>>> On date Friday 2008-05-30 17:21:34 +0100, M?ns Rullg?rd encoded:
>>>> Stefano Sabatini <stefano.sabatini-lala at poste.it> writes:
>>>>
>>>>> Hi all,
>>>>>
>>>>> putenv expects a char* when we feed it with a const char*, this fixes
>>>>> the resulting warning:
>>>>> ffserver.c: In function ?main?:
>>>>> ffserver.c:4388: warning: passing argument 1 of ?putenv? discards qualifiers from pointer target type
>>> [...]
>>>
>>>>> Index: ffserver.c
>>>>> ===================================================================
>>>>> --- ffserver.c	(revision 13552)
>>>>> +++ ffserver.c	(working copy)
>>>>> @@ -4385,7 +4385,7 @@
>>>>>  
>>>>>      parse_options(argc, argv, options, NULL);
>>>>>  
>>>>> -    putenv("http_proxy");               /* Kill the http_proxy */
>>>>> +    putenv(av_strdup("http_proxy"));    /* Kill the http_proxy */
>>>> Beautiful memory leak.
>>> Hi.
>>>
>>> Is a string left on the heap really a problem? also the alternative
>>> solution (attached) looks quite ugly, also keeping the warning doesn't
>>> look like a nice solution.
>>>
>> What about using unsetenv ?
> 
> Allright ;)
> 
> Regards.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: ffserver.c
> ===================================================================
> --- ffserver.c	(revision 13630)
> +++ ffserver.c	(working copy)
> @@ -4385,7 +4385,7 @@
>  
>      parse_options(argc, argv, options, NULL);
>  
> -    putenv("http_proxy");               /* Kill the http_proxy */
> +    unsetenv("http_proxy");             /* Kill the http_proxy */
>  
>      av_init_random(av_gettime() + (getpid() << 16), &random_state);
>  

Patch ok and applied.

-- 
Baptiste COUDURIER                              GnuPG Key Id: 0x5C1ABAAA
Smartjog USA Inc.                                http://www.smartjog.com
Key fingerprint                 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA




More information about the ffmpeg-devel mailing list