OSDN Git Service

Fix compiler warning in bigmstrcmp().
authorFujii Masao <fujii@postgresql.org>
Tue, 4 Feb 2020 12:20:19 +0000 (21:20 +0900)
committerFujii Masao <fujii@postgresql.org>
Tue, 4 Feb 2020 12:22:53 +0000 (21:22 +0900)
Commit 86d78ef in PostgreSQL caused the compiler to report
the following warning when compiling pg_bigm on PostgreSQL 12
or later. This commit fixes it.

    warning: inline function 'bigmstrcmp' declared but never defined [enabled by default]

To suppress the compiler warning, this commit gets rid of
"extern inline" declaration for bigmstrcmp() and moves its definition
into the header file as "static inline" function.

Back-patch to pg_bigm 1.0. Since pg_bigm 1.1 and 1.0 don't support
PostgreSQL 12 or later, basically this commit doesn't need
to be back-patch to 1.1 and 1.0. But we do that because making
the code look similar in all branches for the ease of future
maintenance.

Author: Torikoshi Atsushi
Reviewed-by: Fujii Masao
Discussion: https://osdn.net/projects/pgbigm/lists/archive/hackers/2020-February/000327.html

bigm.h
bigm_op.c

diff --git a/bigm.h b/bigm.h
index 736b43d..7ab9932 100644 (file)
--- a/bigm.h
+++ b/bigm.h
@@ -46,7 +46,25 @@ typedef struct
 
 #define BIGMSIZE       sizeof(bigm)
 
-extern inline int      bigmstrcmp(char *arg1, int len1, char *arg2, int len2);
+static inline int
+bigmstrcmp(char *arg1, int len1, char *arg2, int len2)
+{
+       int                     i;
+       int                     len = Min(len1, len2);
+
+       for (i = 0; i < len; i++, arg1++, arg2++)
+       {
+               if (*arg1 == *arg2)
+                       continue;
+               if (*arg1 < *arg2)
+                       return -1;
+               else
+                       return 1;
+       }
+
+       return (len1 == len2) ? 0 : ((len1 < len2) ? -1 : 1);
+}
+
 #define CMPBIGM(a,b) ( bigmstrcmp(((bigm *)a)->str, ((bigm *)a)->bytelen, ((bigm *)b)->str, ((bigm *)b)->bytelen) )
 
 #define CPBIGM(bptr, s, len) do {              \
index 713c999..80ce28f 100644 (file)
--- a/bigm_op.c
+++ b/bigm_op.c
@@ -708,25 +708,6 @@ likequery(PG_FUNCTION_ARGS)
        PG_RETURN_TEXT_P(result);
 }
 
-inline int
-bigmstrcmp(char *arg1, int len1, char *arg2, int len2)
-{
-       int                     i;
-       int                     len = Min(len1, len2);
-
-       for (i = 0; i < len; i++, arg1++, arg2++)
-       {
-               if (*arg1 == *arg2)
-                       continue;
-               if (*arg1 < *arg2)
-                       return -1;
-               else
-                       return 1;
-       }
-
-       return (len1 == len2) ? 0 : ((len1 < len2) ? -1 : 1);
-}
-
 Datum
 bigmtextcmp(PG_FUNCTION_ARGS)
 {