grosjo / fts-xapian

Dovecot FTS plugin based on Xapian
GNU Lesser General Public License v2.1
97 stars 21 forks source link

Compilation warnings on FreeBSD with clang 10.0.1 #60

Closed jurajlutter closed 4 years ago

jurajlutter commented 4 years ago

Hi,

while building fts-xapian on FreeBSD (I'm mail/dovecot-fts-xapian maintainer), some warnings are shown:

In file included from fts-backend-xapian.cpp:61:
./fts-backend-xapian-functions.cpp:649:90: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        if(verbose>0) i_info("FTS Xapian: Expunging '%s' : %d to do, doing %d",backend->boxname,result->size,j);
                                                           ~~                                   ^~~~~~~~~~~~
                                                           %ld
./fts-backend-xapian-functions.cpp:649:103: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
        if(verbose>0) i_info("FTS Xapian: Expunging '%s' : %d to do, doing %d",backend->boxname,result->size,j);
                                                                           ~~                                ^
                                                                           %ld
./fts-backend-xapian-functions.cpp:669:50: warning: more '%' conversions than data arguments [-Wformat]
                        s = i_strdup_printf("Expunging UID=%d '%s' : %s",docid,backend->boxname);
                                                                     ~^
./fts-backend-xapian-functions.cpp:871:79: warning: format specifies type 'int' but the argument has type 'long' [-Wformat]
                if(verbose>0) { i_info("FTS Xapian: Ngram(%s) -> %d items (total %ld KB)",h,ngram->size, ngram->memory/1024); }
                                                                 ~~                         ^~~~~~~~~~~
                                                                 %ld
fts-backend-xapian.cpp:657:2: warning: mixture of designated and non-designated initializers in the same initializer list is a C99 extension [-Wc99-designator]
        .name = "xapian",
        ^~~~~~~~~~~~~~~~
fts-backend-xapian.cpp:659:2: note: first non-designated initializer is here
        {
        ^

Some of them are quite easy to fix (using %ld in place of %d on apropriate places. If this is not to be upstreamed, we can keep this patched locally in FreeBSD ports), but the line i_strdup_printf("Expunging UID=%d '%s' : %s",docid,backend->boxname) will need some care from someone who knows what that function should print. I would also suggest to fully unfold the fts_backend_xapian definition with full structure member names included.

Thanks.

jurajlutter commented 4 years ago

The last warning (about mixture of designated and non-designated initializers) can be silenced by:

--- src/fts-backend-xapian.cpp.orig     2020-10-23 07:37:57 UTC
+++ src/fts-backend-xapian.cpp
@@ -656,7 +656,7 @@ static int fts_backend_xapian_lookup_multi (struct fts
 struct fts_backend fts_backend_xapian = {
        .name = "xapian",
        .flags = FTS_BACKEND_FLAG_BUILD_FULL_WORDS,
-       {
+       .v = {
                fts_backend_xapian_alloc,
                fts_backend_xapian_init,
                fts_backend_xapian_deinit,
grosjo commented 4 years ago

Please review according changes in latest commit