diff mbox series

[FFmpeg-devel,6/6] avformat/udp: cosmetics

Message ID 1602686103-3427-6-git-send-email-lance.lmwang@gmail.com
State Accepted
Commit 6fb2bdd1d01097a76ea6b2b81d02edb7278a5e29
Headers show
Series [FFmpeg-devel,1/6] avformat/rtpdec: update the previous with new seq | expand

Checks

Context Check Description
andriy/PPC64_make warning Make failed
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Lance Wang Oct. 14, 2020, 2:35 p.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/udp.c | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

Comments

Lance Wang Oct. 21, 2020, 1:47 p.m. UTC | #1
On Wed, Oct 14, 2020 at 10:35:03PM +0800, lance.lmwang@gmail.com wrote:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/udp.c | 31 +++++++++++++++----------------
>  1 file changed, 15 insertions(+), 16 deletions(-)
> 
> diff --git a/libavformat/udp.c b/libavformat/udp.c
> index ee5fa84..0ff7deb 100644
> --- a/libavformat/udp.c
> +++ b/libavformat/udp.c
> @@ -190,7 +190,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc
>          if (local_addr)
>              mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
>          else
> -            mreq.imr_interface.s_addr= INADDR_ANY;
> +            mreq.imr_interface.s_addr = INADDR_ANY;
>          if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
>              ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
>              return -1;
> @@ -203,7 +203,7 @@ static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc
>  
>          memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
>          //TODO: Interface index should be looked up from local_addr
> -        mreq6.ipv6mr_interface= 0;
> +        mreq6.ipv6mr_interface = 0;
>          if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
>              ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
>              return -1;
> @@ -221,9 +221,9 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so
>  
>          mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
>          if (local_addr)
> -            mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
> +            mreq.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr;
>          else
> -            mreq.imr_interface.s_addr= INADDR_ANY;
> +            mreq.imr_interface.s_addr = INADDR_ANY;
>          if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
>              ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)");
>              return -1;
> @@ -236,7 +236,7 @@ static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so
>  
>          memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
>          //TODO: Interface index should be looked up from local_addr
> -        mreq6.ipv6mr_interface= 0;
> +        mreq6.ipv6mr_interface = 0;
>          if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
>              ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)");
>              return -1;
> @@ -295,9 +295,9 @@ static int udp_set_multicast_sources(URLContext *h,
>  
>          mreqs.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
>          if (local_addr)
> -            mreqs.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
> +            mreqs.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr;
>          else
> -            mreqs.imr_interface.s_addr= INADDR_ANY;
> +            mreqs.imr_interface.s_addr = INADDR_ANY;
>          mreqs.imr_sourceaddr.s_addr = ((struct sockaddr_in *)&sources[i])->sin_addr.s_addr;
>  
>          if (setsockopt(sockfd, IPPROTO_IP,
> @@ -545,7 +545,7 @@ static void *circular_buffer_task_tx( void *_URLContext)
>          uint8_t tmp[4];
>          int64_t timestamp;
>  
> -        len=av_fifo_size(s->fifo);
> +        len = av_fifo_size(s->fifo);
>  
>          while (len<4) {
>              if (s->close_req)
> @@ -553,11 +553,11 @@ static void *circular_buffer_task_tx( void *_URLContext)
>              if (pthread_cond_wait(&s->cond, &s->mutex) < 0) {
>                  goto end;
>              }
> -            len=av_fifo_size(s->fifo);
> +            len = av_fifo_size(s->fifo);
>          }
>  
>          av_fifo_generic_read(s->fifo, tmp, 4, NULL);
> -        len=AV_RL32(tmp);
> +        len = AV_RL32(tmp);
>  
>          av_assert0(len >= 0);
>          av_assert0(len <= sizeof(s->tmp));
> @@ -956,10 +956,10 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
>                  uint8_t tmp[4];
>  
>                  av_fifo_generic_read(s->fifo, tmp, 4, NULL);
> -                avail= AV_RL32(tmp);
> +                avail = AV_RL32(tmp);
>                  if(avail > size){
>                      av_log(h, AV_LOG_WARNING, "Part of datagram lost due to insufficient buffer size\n");
> -                    avail= size;
> +                    avail = size;
>                  }
>  
>                  av_fifo_generic_read(s->fifo, buf, avail, NULL);
> @@ -973,8 +973,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
>              } else if(nonblock) {
>                  pthread_mutex_unlock(&s->mutex);
>                  return AVERROR(EAGAIN);
> -            }
> -            else {
> +            } else {
>                  /* FIXME: using the monotonic clock would be better,
>                     but it does not exist on all supported platforms. */
>                  int64_t t = av_gettime() + 100000;
> @@ -987,7 +986,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
>                  }
>                  nonblock = 1;
>              }
> -        } while( 1);
> +        } while(1);
>      }
>  #endif
>  
> @@ -1020,7 +1019,7 @@ static int udp_write(URLContext *h, const uint8_t *buf, int size)
>            Here we can't know on which packet error was, but it needs to know that error exists.
>          */
>          if (s->circular_buffer_error<0) {
> -            int err=s->circular_buffer_error;
> +            int err = s->circular_buffer_error;
>              pthread_mutex_unlock(&s->mutex);
>              return err;
>          }
> -- 
> 1.8.3.1
> 

will apply the patchset(with one local spacing fix and except first patch) tomorrow if no more comments.
diff mbox series

Patch

diff --git a/libavformat/udp.c b/libavformat/udp.c
index ee5fa84..0ff7deb 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -190,7 +190,7 @@  static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc
         if (local_addr)
             mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
         else
-            mreq.imr_interface.s_addr= INADDR_ANY;
+            mreq.imr_interface.s_addr = INADDR_ANY;
         if (setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_ADD_MEMBERSHIP)");
             return -1;
@@ -203,7 +203,7 @@  static int udp_join_multicast_group(int sockfd, struct sockaddr *addr,struct soc
 
         memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
         //TODO: Interface index should be looked up from local_addr
-        mreq6.ipv6mr_interface= 0;
+        mreq6.ipv6mr_interface = 0;
         if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_ADD_MEMBERSHIP)");
             return -1;
@@ -221,9 +221,9 @@  static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so
 
         mreq.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
         if (local_addr)
-            mreq.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
+            mreq.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr;
         else
-            mreq.imr_interface.s_addr= INADDR_ANY;
+            mreq.imr_interface.s_addr = INADDR_ANY;
         if (setsockopt(sockfd, IPPROTO_IP, IP_DROP_MEMBERSHIP, (const void *)&mreq, sizeof(mreq)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IP_DROP_MEMBERSHIP)");
             return -1;
@@ -236,7 +236,7 @@  static int udp_leave_multicast_group(int sockfd, struct sockaddr *addr,struct so
 
         memcpy(&mreq6.ipv6mr_multiaddr, &(((struct sockaddr_in6 *)addr)->sin6_addr), sizeof(struct in6_addr));
         //TODO: Interface index should be looked up from local_addr
-        mreq6.ipv6mr_interface= 0;
+        mreq6.ipv6mr_interface = 0;
         if (setsockopt(sockfd, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP, &mreq6, sizeof(mreq6)) < 0) {
             ff_log_net_error(NULL, AV_LOG_ERROR, "setsockopt(IPV6_DROP_MEMBERSHIP)");
             return -1;
@@ -295,9 +295,9 @@  static int udp_set_multicast_sources(URLContext *h,
 
         mreqs.imr_multiaddr.s_addr = ((struct sockaddr_in *)addr)->sin_addr.s_addr;
         if (local_addr)
-            mreqs.imr_interface= ((struct sockaddr_in *)local_addr)->sin_addr;
+            mreqs.imr_interface = ((struct sockaddr_in *)local_addr)->sin_addr;
         else
-            mreqs.imr_interface.s_addr= INADDR_ANY;
+            mreqs.imr_interface.s_addr = INADDR_ANY;
         mreqs.imr_sourceaddr.s_addr = ((struct sockaddr_in *)&sources[i])->sin_addr.s_addr;
 
         if (setsockopt(sockfd, IPPROTO_IP,
@@ -545,7 +545,7 @@  static void *circular_buffer_task_tx( void *_URLContext)
         uint8_t tmp[4];
         int64_t timestamp;
 
-        len=av_fifo_size(s->fifo);
+        len = av_fifo_size(s->fifo);
 
         while (len<4) {
             if (s->close_req)
@@ -553,11 +553,11 @@  static void *circular_buffer_task_tx( void *_URLContext)
             if (pthread_cond_wait(&s->cond, &s->mutex) < 0) {
                 goto end;
             }
-            len=av_fifo_size(s->fifo);
+            len = av_fifo_size(s->fifo);
         }
 
         av_fifo_generic_read(s->fifo, tmp, 4, NULL);
-        len=AV_RL32(tmp);
+        len = AV_RL32(tmp);
 
         av_assert0(len >= 0);
         av_assert0(len <= sizeof(s->tmp));
@@ -956,10 +956,10 @@  static int udp_read(URLContext *h, uint8_t *buf, int size)
                 uint8_t tmp[4];
 
                 av_fifo_generic_read(s->fifo, tmp, 4, NULL);
-                avail= AV_RL32(tmp);
+                avail = AV_RL32(tmp);
                 if(avail > size){
                     av_log(h, AV_LOG_WARNING, "Part of datagram lost due to insufficient buffer size\n");
-                    avail= size;
+                    avail = size;
                 }
 
                 av_fifo_generic_read(s->fifo, buf, avail, NULL);
@@ -973,8 +973,7 @@  static int udp_read(URLContext *h, uint8_t *buf, int size)
             } else if(nonblock) {
                 pthread_mutex_unlock(&s->mutex);
                 return AVERROR(EAGAIN);
-            }
-            else {
+            } else {
                 /* FIXME: using the monotonic clock would be better,
                    but it does not exist on all supported platforms. */
                 int64_t t = av_gettime() + 100000;
@@ -987,7 +986,7 @@  static int udp_read(URLContext *h, uint8_t *buf, int size)
                 }
                 nonblock = 1;
             }
-        } while( 1);
+        } while(1);
     }
 #endif
 
@@ -1020,7 +1019,7 @@  static int udp_write(URLContext *h, const uint8_t *buf, int size)
           Here we can't know on which packet error was, but it needs to know that error exists.
         */
         if (s->circular_buffer_error<0) {
-            int err=s->circular_buffer_error;
+            int err = s->circular_buffer_error;
             pthread_mutex_unlock(&s->mutex);
             return err;
         }