[1/2] rtsp: Fix compiler warning for uninitialized variable

Message ID 1325683315-54690-1-git-send-email-martin@martin.st
State Committed
Commit 4be386b318e2c707f3f65df49244768afc47c3d9
Headers show

Commit Message

Martin Storsjö Jan. 4, 2012, 1:21 p.m.
From: Jean First <jeanfirst@gmail.com>

This one won't ever be used uninitialized in practice, but
the compiler doesn't realize it.

Signed-off-by: Martin Storsjö <martin@martin.st>
---
 libavformat/rtsp.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Diego Biurrun Jan. 4, 2012, 1:36 p.m. | #1
On Wed, Jan 04, 2012 at 03:21:54PM +0200, Martin Storsjö wrote:
> From: Jean First <jeanfirst@gmail.com>
> 
> This one won't ever be used uninitialized in practice, but
> the compiler doesn't realize it.
> 
> Signed-off-by: Martin Storsjö <martin@martin.st>
> ---
>  libavformat/rtsp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

OK I guess if you want to silence the warning.

Diego
Ronald Bultje Jan. 4, 2012, 3:27 p.m. | #2
Hi,

On Wed, Jan 4, 2012 at 5:21 AM, Martin Storsjö <martin@martin.st> wrote:
> From: Jean First <jeanfirst@gmail.com>
>
> This one won't ever be used uninitialized in practice, but
> the compiler doesn't realize it.
>
> Signed-off-by: Martin Storsjö <martin@martin.st>
> ---
>  libavformat/rtsp.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Didn't we have av_uninitialized_safe or so for that?

Ronald
Martin Storsjö Jan. 4, 2012, 3:52 p.m. | #3
On Wed, 4 Jan 2012, Ronald S. Bultje wrote:

> On Wed, Jan 4, 2012 at 5:21 AM, Martin Storsjö <martin@martin.st> wrote:
>> From: Jean First <jeanfirst@gmail.com>
>>
>> This one won't ever be used uninitialized in practice, but
>> the compiler doesn't realize it.
>>
>> Signed-off-by: Martin Storsjö <martin@martin.st>
>> ---
>>  libavformat/rtsp.c |    2 +-
>>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> Didn't we have av_uninitialized_safe or so for that?

Yes, av_uninit, but I prefer a proper initialization, since the av_uninit 
declaration would hide the issue if we later change the code so that it 
suddenly could be used uninitialized. Also, in this case, it really isn't 
performance critical.

// Martin
Ronald Bultje Jan. 4, 2012, 7:01 p.m. | #4
Hi,

On Wed, Jan 4, 2012 at 7:52 AM, Martin Storsjö <martin@martin.st> wrote:
> On Wed, 4 Jan 2012, Ronald S. Bultje wrote:
>> On Wed, Jan 4, 2012 at 5:21 AM, Martin Storsjö <martin@martin.st> wrote:
>>> From: Jean First <jeanfirst@gmail.com>
>>> This one won't ever be used uninitialized in practice, but
>>> the compiler doesn't realize it.
>>>
>>> Signed-off-by: Martin Storsjö <martin@martin.st>
>>> ---
>>>  libavformat/rtsp.c |    2 +-
>>>  1 files changed, 1 insertions(+), 1 deletions(-)
>>
>> Didn't we have av_uninitialized_safe or so for that?
>
> Yes, av_uninit, but I prefer a proper initialization, since the av_uninit
> declaration would hide the issue if we later change the code so that it
> suddenly could be used uninitialized. Also, in this case, it really isn't
> performance critical.

Either way fine with me, so go for it.

Ronald

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index fcf168d..2858a9a 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1103,7 +1103,7 @@  int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
                               int lower_transport, const char *real_challenge)
 {
     RTSPState *rt = s->priv_data;
-    int rtx, j, i, err, interleave = 0;
+    int rtx = 0, j, i, err, interleave = 0;
     RTSPStream *rtsp_st;
     RTSPMessageHeader reply1, *reply = &reply1;
     char cmd[2048];