pgagroal icon indicating copy to clipboard operation
pgagroal copied to clipboard

`uncrustify.cfg` problems

Open fluca1978 opened this issue 1 year ago • 3 comments

Seems that the uncrustify.cfg configuration file has deprecated or not-valid options.

With a recent version of uncrustify:

$ uncrustify --version
Uncrustify_d-0.75.1_f

$ sh uncrustify.sh 
.... # a lot of messages repeated as follows
uncrustify.cfg:472: option 'sp_type_question' is deprecated; did you want to use 'sp_before_ptr_star' instead?
Option<NUM>: at uncrustify.cfg:1182: Expected number , for 'indent_shift'; got 'false'
Option<NUM>: at uncrustify.cfg:1356: Expected number , for 'indent_comma_brace'; got 'false'
Option<NUM>: at uncrustify.cfg:1360: Expected number , for 'indent_comma_paren'; got 'false'
Option<NUM>: at uncrustify.cfg:1364: Expected number , for 'indent_bool_paren'; got 'false'
Option<UNUM>: at uncrustify.cfg:2988: Expected unsigned number , for 'mod_full_brace_if_chain'; got 'false'
Option<NUM>: at uncrustify.cfg:3217: Expected number , for 'pp_indent_brace'; got 'true'

with an older version:

$ uncrustify --version
Uncrustify_d-0.72.0_f


$ sh uncrustify.sh
 ... # a lot of repreated messages as follows
uncrustify.cfg:1356: unknown option 'indent_comma_brace'
uncrustify.cfg:1541: unknown option 'nl_do_leave_one_liners'
uncrustify.cfg:1997: unknown option 'nl_before_brace_open'
uncrustify.cfg:2083: unknown option 'nl_before_ignore_after_case'
uncrustify.cfg:2281: unknown option 'nl_before_struct'
uncrustify.cfg:2696: unknown option 'align_func_proto_star_style'
uncrustify.cfg:2704: unknown option 'align_func_proto_amp_style'
uncrustify.cfg:2825: unknown option 'cmt_reflow_fold_regex_file'
uncrustify.cfg:2833: unknown option 'cmt_reflow_indent_to_paragraph_start'
uncrustify.cfg:2851: unknown option 'cmt_align_doxygen_javadoc_tags'
uncrustify.cfg:2859: unknown option 'cmt_sp_before_doxygen_javadoc_tags'


fluca1978 avatar Feb 08 '24 15:02 fluca1978

I did some related work in https://github.com/pgmoneta/pgmoneta/commit/607a4a1f53a79c356b293d32941a8da1ee1a6f42

jesperpedersen avatar Feb 08 '24 15:02 jesperpedersen

Commit 189c5f7 silents all the warnings, and works with uncrustify 0.78. One problem I see, is that after a run of uncrustify.sh the multiline macros are changed as the diff that follows. I've not committed the changes to the macros because I'm not sure this is what we want or is a mispelled configuration in my commit. I think the macro alignment is something we should not worry too much.

$ git diff upstream/master
diff --git a/src/include/pgagroal.h b/src/include/pgagroal.h
index c4dff95..b6b2e4a 100644
--- a/src/include/pgagroal.h
+++ b/src/include/pgagroal.h
@@ -174,14 +174,14 @@ extern "C" {
 #define unlikely(x)  __builtin_expect (!!(x), 0)
 
 #define MAX(a, b)               \
-   ({ __typeof__ (a) _a = (a);  \
-      __typeof__ (b) _b = (b);  \
-      _a > _b ? _a : _b; })
+        ({ __typeof__ (a) _a = (a);  \
+           __typeof__ (b) _b = (b);  \
+           _a > _b ? _a : _b; })
 
 #define MIN(a, b)               \
-   ({ __typeof__ (a) _a = (a);  \
-      __typeof__ (b) _b = (b);  \
-      _a < _b ? _a : _b; })
+        ({ __typeof__ (a) _a = (a);  \
+           __typeof__ (b) _b = (b);  \
+           _a < _b ? _a : _b; })
 
 /*
  * Common piece of code to perform a sleeping.
@@ -194,13 +194,13 @@ extern "C" {
  *
  */
 #define SLEEP(zzz)                  \
-   do                               \
-   {                                \
-      struct timespec ts_private;   \
-      ts_private.tv_sec = 0;        \
-      ts_private.tv_nsec = zzz;     \
-      nanosleep(&ts_private, NULL); \
-   } while (0);
+        do                               \
+        {                                \
+           struct timespec ts_private;   \
+           ts_private.tv_sec = 0;        \
+           ts_private.tv_nsec = zzz;     \
+           nanosleep(&ts_private, NULL); \
+        } while (0);
 
 /*
  * Commonly used block of code to sleep
@@ -217,14 +217,14 @@ extern "C" {
        SLEEP_AND_GOTO(100000L, retry)
  */
 #define SLEEP_AND_GOTO(zzz, goto_to)    \
-   do                                   \
-   {                                    \
-      struct timespec ts_private;       \
-      ts_private.tv_sec = 0;            \
-      ts_private.tv_nsec = zzz;         \
-      nanosleep(&ts_private, NULL);     \
-      goto goto_to;                     \
-   } while (0);
+        do                                   \
+        {                                    \
+           struct timespec ts_private;       \
+           ts_private.tv_sec = 0;            \
+           ts_private.tv_nsec = zzz;         \
+           nanosleep(&ts_private, NULL);     \
+           goto goto_to;                     \
+        } while (0);
 
 /**
  * The shared memory segment

fluca1978 avatar Feb 08 '24 16:02 fluca1978

Sure, you can leave those out - I'll look at it

jesperpedersen avatar Feb 08 '24 16:02 jesperpedersen