]> git.sesse.net Git - x264/commitdiff
Silence various static analyzer warnings
authorHenrik Gramner <henrik@gramner.com>
Wed, 29 Jul 2015 17:30:41 +0000 (19:30 +0200)
committerAnton Mitrofanov <BugMaster@narod.ru>
Tue, 18 Aug 2015 22:00:18 +0000 (01:00 +0300)
Those are false positives, but it doesn't hurt to get rid of them.

common/common.c
common/common.h
encoder/encoder.c
encoder/me.c
input/avs.c

index 273334a1229d1bec618f66048f841df19b0242a4..6999a0060af82bcd795b9896a4d03cb8db0fe385 100644 (file)
@@ -582,7 +582,6 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
     int errortype = X264_PARAM_BAD_VALUE;
     int name_was_bool;
     int value_was_null = !value;
-    int i;
 
     if( !name )
         return X264_PARAM_BAD_NAME;
@@ -603,10 +602,11 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
         name = name_buf;
     }
 
-    if( (!strncmp( name, "no-", 3 ) && (i = 3)) ||
-        (!strncmp( name, "no", 2 ) && (i = 2)) )
+    if( !strncmp( name, "no", 2 ) )
     {
-        name += i;
+        name += 2;
+        if( name[0] == '-' )
+            name++;
         value = atobool(value) ? "false" : "true";
     }
     name_was_bool = 0;
@@ -628,7 +628,9 @@ int x264_param_parse( x264_param_t *p, const char *name, const char *value )
                 p->cpu = 0;
                 for( init=buf; (tok=strtok_r(init, ",", &saveptr)); init=NULL )
                 {
-                    for( i=0; x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name); i++ );
+                    int i = 0;
+                    while( x264_cpu_names[i].flags && strcasecmp(tok, x264_cpu_names[i].name) )
+                        i++;
                     p->cpu |= x264_cpu_names[i].flags;
                     if( !x264_cpu_names[i].flags )
                         b_error = 1;
index 7d5e5fbc08e2834bebc4ee0e4601c657bc27a150..9cda1871ac4356a4908414d1407f74554b18a61c 100644 (file)
@@ -895,9 +895,6 @@ struct x264_t
     /* stats */
     struct
     {
-        /* Current frame stats */
-        x264_frame_stat_t frame;
-
         /* Cumulated stats */
 
         /* per slice info */
@@ -927,6 +924,8 @@ struct x264_t
         /* num p-frames weighted */
         int     i_wpred[2];
 
+        /* Current frame stats */
+        x264_frame_stat_t frame;
     } stat;
 
     /* 0 = luma 4x4, 1 = luma 8x8, 2 = chroma 4x4, 3 = chroma 8x8 */
index fd77f48abcdbd1fed920e969a2553e5bcf228bf4..79997b96ef82fda8838e1eaeeeb7551a3d1aa651 100644 (file)
@@ -1010,9 +1010,9 @@ static int x264_validate_parameters( x264_t *h, int b_open )
         h->param.i_fps_num = 25;
         h->param.i_fps_den = 1;
     }
-    float fps = (float) h->param.i_fps_num / h->param.i_fps_den;
+    float fps = (float)h->param.i_fps_num / h->param.i_fps_den;
     if( h->param.i_keyint_min == X264_KEYINT_MIN_AUTO )
-        h->param.i_keyint_min = X264_MIN( h->param.i_keyint_max / 10, fps );
+        h->param.i_keyint_min = X264_MIN( h->param.i_keyint_max / 10, (int)fps );
     h->param.i_keyint_min = x264_clip3( h->param.i_keyint_min, 1, h->param.i_keyint_max/2+1 );
     h->param.rc.i_lookahead = x264_clip3( h->param.rc.i_lookahead, 0, X264_LOOKAHEAD_MAX );
     {
@@ -3043,9 +3043,8 @@ static void x264_thread_sync_context( x264_t *dst, x264_t *src )
 
 static void x264_thread_sync_stat( x264_t *dst, x264_t *src )
 {
-    if( dst == src )
-        return;
-    memcpy( &dst->stat.i_frame_count, &src->stat.i_frame_count, sizeof(dst->stat) - sizeof(dst->stat.frame) );
+    if( dst != src )
+        memcpy( &dst->stat, &src->stat, offsetof(x264_t, stat.frame) - offsetof(x264_t, stat) );
 }
 
 static void *x264_slices_write( x264_t *h )
index d34644d6c9c31cf73c38e84cf4d5a5ce7d28eca4..809656895bbab8e717875e8804ae97df956ec9e9 100644 (file)
@@ -707,10 +707,11 @@ void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc,
                 sad_thresh = bsad*sad_thresh>>3;
                 while( nmvsad > limit*2 && sad_thresh > bsad )
                 {
-                    int i;
+                    int i = 0;
                     // halve the range if the domain is too large... eh, close enough
                     sad_thresh = (sad_thresh + bsad) >> 1;
-                    for( i = 0; i < nmvsad && mvsads[i].sad <= sad_thresh; i++ );
+                    while( i < nmvsad && mvsads[i].sad <= sad_thresh )
+                        i++;
                     for( int j = i; j < nmvsad; j++ )
                     {
                         uint32_t sad;
index 3e4c8e574012f2239746ab2afd9ccd45b70c352d..71670b63ce5da75e92a47ac4891d8b616d9e2d07 100644 (file)
@@ -283,8 +283,8 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
                        "input clip height not divisible by 4 (%dx%d)\n", vi->width, vi->height )
         FAIL_IF_ERROR( (opt->output_csp == X264_CSP_I420 || info->interlaced) && (vi->height&1),
                        "input clip height not divisible by 2 (%dx%d)\n", vi->width, vi->height )
-        char conv_func[14] = { "ConvertTo" };
-        strcat( conv_func, csp );
+        char conv_func[14];
+        snprintf( conv_func, sizeof(conv_func), "ConvertTo%s", csp );
         char matrix[7] = "";
         int arg_count = 2;
         /* if doing a rgb <-> yuv conversion then range is handled via 'matrix'. though it's only supported in 2.56+ */
@@ -292,8 +292,7 @@ static int open_file( char *psz_filename, hnd_t *p_handle, video_info_t *info, c
         {
             // if converting from yuv, then we specify the matrix for the input, otherwise use the output's.
             int use_pc_matrix = avs_is_yuv( vi ) ? opt->input_range == RANGE_PC : opt->output_range == RANGE_PC;
-            strcpy( matrix, use_pc_matrix ? "PC." : "Rec" );
-            strcat( matrix, "601" ); /* FIXME: use correct coefficients */
+            snprintf( matrix, sizeof(matrix), "%s601", use_pc_matrix ? "PC." : "Rec" ); /* FIXME: use correct coefficients */
             arg_count++;
             // notification that the input range has changed to the desired one
             opt->input_range = opt->output_range;