Message ID | 20200714062353.20419-1-lq@chinaffmpeg.org |
---|---|
State | Accepted |
Commit | 2c1cc326e9a76f4d0a1b30345f4b803272efde17 |
Headers | show |
Series | [FFmpeg-devel,v2] avformat/crypto.c: remove unnecessary code | expand |
Context | Check | Description |
---|---|---|
andriy/default | pending | |
andriy/make | success | Make finished |
andriy/make_fate | success | Make fate finished |
tis 2020-07-14 klockan 14:23 +0800 skrev Steven Liu: > Because the newpos variable is set value before use it. > The newpos variable declared at the head partition of crypto_seek. > Make the code clean. > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > --- > libavformat/crypto.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/libavformat/crypto.c b/libavformat/crypto.c > index 31f9ac0ab9..1d4514e0f2 100644 > --- a/libavformat/crypto.c > +++ b/libavformat/crypto.c > @@ -252,21 +252,17 @@ static int64_t crypto_seek(URLContext *h, int64_t pos, int whence) > case SEEK_CUR: > pos = pos + c->position; > break; > - case SEEK_END: { > - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > + case SEEK_END: > + newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > if (newpos < 0) { > av_log(h, AV_LOG_ERROR, > "Crypto: seek_end - can't get file size (pos=%lld)\r\n", (long long int)pos); > return newpos; > } > pos = newpos - pos; > - } > - break; > - case AVSEEK_SIZE: { > - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > - return newpos; > - } > break; > + case AVSEEK_SIZE: > + return ffurl_seek( c->hd, pos, AVSEEK_SIZE ); Looks OK enough. /Tomas
Tomas Härdin <tjoppen@acc.umu.se> 于2020年7月14日周二 下午4:48写道: > > tis 2020-07-14 klockan 14:23 +0800 skrev Steven Liu: > > Because the newpos variable is set value before use it. > > The newpos variable declared at the head partition of crypto_seek. > > Make the code clean. > > > > Signed-off-by: Steven Liu <lq@chinaffmpeg.org> > > --- > > libavformat/crypto.c | 12 ++++-------- > > 1 file changed, 4 insertions(+), 8 deletions(-) > > > > diff --git a/libavformat/crypto.c b/libavformat/crypto.c > > index 31f9ac0ab9..1d4514e0f2 100644 > > --- a/libavformat/crypto.c > > +++ b/libavformat/crypto.c > > @@ -252,21 +252,17 @@ static int64_t crypto_seek(URLContext *h, int64_t pos, int whence) > > case SEEK_CUR: > > pos = pos + c->position; > > break; > > - case SEEK_END: { > > - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > > + case SEEK_END: > > + newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > > if (newpos < 0) { > > av_log(h, AV_LOG_ERROR, > > "Crypto: seek_end - can't get file size (pos=%lld)\r\n", (long long int)pos); > > return newpos; > > } > > pos = newpos - pos; > > - } > > - break; > > - case AVSEEK_SIZE: { > > - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > > - return newpos; > > - } > > break; > > + case AVSEEK_SIZE: > > + return ffurl_seek( c->hd, pos, AVSEEK_SIZE ); > > Looks OK enough. Will push this patch if there have no objections. > > /Tomas Thanks Steven
diff --git a/libavformat/crypto.c b/libavformat/crypto.c index 31f9ac0ab9..1d4514e0f2 100644 --- a/libavformat/crypto.c +++ b/libavformat/crypto.c @@ -252,21 +252,17 @@ static int64_t crypto_seek(URLContext *h, int64_t pos, int whence) case SEEK_CUR: pos = pos + c->position; break; - case SEEK_END: { - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); + case SEEK_END: + newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); if (newpos < 0) { av_log(h, AV_LOG_ERROR, "Crypto: seek_end - can't get file size (pos=%lld)\r\n", (long long int)pos); return newpos; } pos = newpos - pos; - } - break; - case AVSEEK_SIZE: { - int64_t newpos = ffurl_seek( c->hd, pos, AVSEEK_SIZE ); - return newpos; - } break; + case AVSEEK_SIZE: + return ffurl_seek( c->hd, pos, AVSEEK_SIZE ); default: av_log(h, AV_LOG_ERROR, "Crypto: no support for seek where 'whence' is %d\r\n", whence);
Because the newpos variable is set value before use it. The newpos variable declared at the head partition of crypto_seek. Make the code clean. Signed-off-by: Steven Liu <lq@chinaffmpeg.org> --- libavformat/crypto.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)