[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

conflicts.c compiler warnings

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Thu, 29 Jun 2017 03:02:48 +0000

There are some compiler warnings in trunk:

[[[
subversion/libsvn_client/conflicts.c:3846:12: warning: variable 'action' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  else if (conflict_operation == svn_wc_operation_merge)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:3868:59: note: uninitialized use occurs here
  *incoming_change_description = apr_pstrdup(result_pool, action);
                                                          ^~~~~~
subversion/libsvn_client/conflicts.c:3846:8: note: remove the 'if' if its condition is always true
  else if (conflict_operation == svn_wc_operation_merge)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:3781:21: note: initialize the variable 'action' to silence this warning
  const char *action;
                    ^
                     = NULL

subversion/libsvn_client/conflicts.c:4858:12: warning: variable 'action' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  else if (conflict_operation == svn_wc_operation_merge)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:4873:59: note: uninitialized use occurs here
  *incoming_change_description = apr_pstrdup(result_pool, action);
                                                          ^~~~~~
subversion/libsvn_client/conflicts.c:4858:8: note: remove the 'if' if its condition is always true
  else if (conflict_operation == svn_wc_operation_merge)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:4815:21: note: initialize the variable 'action' to silence this warning
  const char *action;
                    ^
                     = NULL

subversion/libsvn_client/conflicts.c:5052:12: warning: variable 'url' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  else if (operation == svn_wc_operation_switch ||
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:5064:48: note: uninitialized use occurs here
                                               url, NULL, NULL,
                                               ^~~
subversion/include/svn_error.h:353:35: note: expanded from macro 'SVN_ERR'
    svn_error_t *svn_err__temp = (expr); \
                                  ^
subversion/libsvn_client/conflicts.c:5052:8: note: remove the 'if' if its condition is always true
  else if (operation == svn_wc_operation_switch ||
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:5019:18: note: initialize the variable 'url' to silence this warning
  const char *url;
                 ^
                  = NULL

subversion/libsvn_client/conflicts.c:5284:12: warning: variable 'action' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
  else if (conflict_operation == svn_wc_operation_merge)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:5392:50: note: uninitialized use occurs here
  action = apr_psprintf(scratch_pool, "%s:\n%s", action,
                                                 ^~~~~~
subversion/libsvn_client/conflicts.c:5284:8: note: remove the 'if' if its condition is always true
  else if (conflict_operation == svn_wc_operation_merge)
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subversion/libsvn_client/conflicts.c:5251:21: note: initialize the variable 'action' to silence this warning
  const char *action;
                    ^
                     = NULL
4 warnings generated.
]]]

I spot checked a few and they look valid, e.g., the 'url' one will cause
undefined behaviour (dereferencing an uninitialised pointer) if neither 'if'
branch is taken.

I assume most of these should either add an «else SVN_ERR_MALFUNCTION();»
branch, or initialise to NULL.

Cheers,

Daniel
Received on 2017-06-29 05:02:59 CEST

This is an archived mail posted to the Subversion Dev mailing list.