[YAMos-dev] diff for format warning on vbcc + inline problem

Hello,

Building yam on vbcc is still quite noisy, due to a bunch of format warnings
"suspicious format string"

All of these are due to the use of %d or %ld for unsigned values. It should be 
instead %u and %lu.
I guess gcc doesn't mind, but not much point in having a %u if it's never used 
:-)

Also there are 2 more errors building YAM on vbcc!

error 302 in line 1031 of "BayesFilter.c": reference to static variable <C_11> 
in inline function with external linkage
>  return a * log (x) - x - nsLnGamma (a, &gsign);
error 302 in line 1108 of "BayesFilter.c": reference to static variable 
<nsLnGamma> in inline function with external linkage

It's the same issue as before. The diff also changes these to not be inline. 
What is the real fix to allow these functions to be inlined on vbcc ?

Best Regards

Jools
-- 
<sb>ExoticA - http://www.exotica.org.uk

Index: src/YAM_WR.c
===================================================================
--- src/YAM_WR.c        (revision 2465)
+++ src/YAM_WR.c        (working copy)
@@ -2571,7 +2571,7 @@
   struct WR_ClassData *wr = G->WR[*arg];
   Object *ed = wr->GUI.TE_EDIT;
 
-  snprintf(wr->WTitle, sizeof(wr->WTitle), "%03ld\n%03ld", 
xget(ed,MUIA_TextEditor_CursorY)+1, xget(ed,MUIA_TextEditor_CursorX)+1);
+  snprintf(wr->WTitle, sizeof(wr->WTitle), "%03lu\n%03lu", 
xget(ed,MUIA_TextEditor_CursorY)+1, xget(ed,MUIA_TextEditor_CursorX)+1);
   set(wr->GUI.TX_POSI, MUIA_Text_Contents, wr->WTitle);
 }
 MakeStaticHook(WR_UpdateWTitleHook,WR_UpdateWTitleFunc);
Index: src/UpdateCheck.c
===================================================================
--- src/UpdateCheck.c   (revision 2465)
+++ src/UpdateCheck.c   (working copy)
@@ -170,47 +170,47 @@
 
           // encode the language in which YAM is running
           if(G->Catalog && urlencode(buf, G->Catalog->cat_Language, SIZE_LINE) 
> 0)
-            snprintf(request, REQUEST_SIZE, "%s&lang=%s%%20%d%%2E%d", request, 
buf, G->Catalog->cat_Version,
+            snprintf(request, REQUEST_SIZE, "%s&lang=%s%%20%u%%2E%u", request, 
buf, G->Catalog->cat_Version,
                                                                                
     G->Catalog->cat_Revision);
 
           // Now we add some third party components
           // information for our update server as well.
 
           // encode the exec version
-          snprintf(request, REQUEST_SIZE, "%s&exec=%d%%2E%d", request, 
((struct Library *)SysBase)->lib_Version,
+          snprintf(request, REQUEST_SIZE, "%s&exec=%u%%2E%u", request, 
((struct Library *)SysBase)->lib_Version,
                                                                        
((struct Library *)SysBase)->lib_Revision);
 
           // add codesets.library information
-          snprintf(request, REQUEST_SIZE, "%s&lib%d=codesets-%d%%2E%d", 
request, cnt++, CodesetsBase->lib_Version,
+          snprintf(request, REQUEST_SIZE, "%s&lib%u=codesets-%u%%2E%u", 
request, cnt++, CodesetsBase->lib_Version,
                                                                                
         CodesetsBase->lib_Revision);
 
           // add AmiSSL library information
           if(AmiSSLMasterBase)
-            snprintf(request, REQUEST_SIZE, "%s&lib%d=amissl-%d%%2E%d", 
request, cnt++, AmiSSLMasterBase->lib_Version,
+            snprintf(request, REQUEST_SIZE, "%s&lib%u=amissl-%u%%2E%u", 
request, cnt++, AmiSSLMasterBase->lib_Version,
                                                                                
         AmiSSLMasterBase->lib_Revision);
 
           // add XPK library information
           if(XpkBase)
-            snprintf(request, REQUEST_SIZE, "%s&lib%d=xpk-%d%%2E%d", request, 
cnt++, XpkBase->lib_Version,
+            snprintf(request, REQUEST_SIZE, "%s&lib%u=xpk-%u%%2E%u", request, 
cnt++, XpkBase->lib_Version,
                                                                                
      XpkBase->lib_Revision);
 
           // add openurl.library information
           if((base = OpenLibrary("openurl.library", 0)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&lib%d=openurl-%d%%2E%d", 
request, cnt++, base->lib_Version,
+            snprintf(request, REQUEST_SIZE, "%s&lib%u=openurl-%u%%2E%u", 
request, cnt++, base->lib_Version,
                                                                                
          base->lib_Revision);
             CloseLibrary(base);
           }
 
           // encode the MUI version
           cnt = 0;
-          snprintf(request, REQUEST_SIZE, "%s&mui=%d%%2E%d", request, 
MUIMasterBase->lib_Version,
+          snprintf(request, REQUEST_SIZE, "%s&mui=%u%%2E%u", request, 
MUIMasterBase->lib_Version,
                                                                       
MUIMasterBase->lib_Revision);
 
           // add Toolbar.mcc version information
           if((mccObj = MUI_NewObject(MUIC_Toolbar, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=toolbar-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=toolbar-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
            xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -218,7 +218,7 @@
           // add TextEditor.mcc version information
           if((mccObj = MUI_NewObject(MUIC_TextEditor, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=texteditor-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=texteditor-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
               xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -226,7 +226,7 @@
           // add BetterString.mcc version information
           if((mccObj = MUI_NewObject(MUIC_BetterString, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, 
"%s&mcc%d=betterstring-%ld%%2E%ld", request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, 
"%s&mcc%u=betterstring-%lu%%2E%lu", request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
                 xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -234,7 +234,7 @@
           // add NList.mcc version information
           if((mccObj = MUI_NewObject(MUIC_NList, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=nlist-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=nlist-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
          xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -242,7 +242,7 @@
           // add NListview.mcc version information
           if((mccObj = MUI_NewObject(MUIC_NListview, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=nlistview-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=nlistview-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
              xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -250,7 +250,7 @@
           // add NFloattext.mcc version information
           if((mccObj = MUI_NewObject(MUIC_NFloattext, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=nfloattext-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=nfloattext-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
               xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
@@ -258,12 +258,12 @@
           // add NListtree.mcc version information
           if((mccObj = MUI_NewObject(MUIC_NListtree, TAG_DONE)))
           {
-            snprintf(request, REQUEST_SIZE, "%s&mcc%d=nlisttree-%ld%%2E%ld", 
request, cnt++, xget(mccObj, MUIA_Version),
+            snprintf(request, REQUEST_SIZE, "%s&mcc%u=nlisttree-%lu%%2E%lu", 
request, cnt++, xget(mccObj, MUIA_Version),
                                                                                
              xget(mccObj, MUIA_Revision));
             MUI_DisposeObject(mccObj);
           }
 
-          D(DBF_UPDATE, "send update request: '%s' (%ld)", request, 
strlen(request));
+          D(DBF_UPDATE, "send update request: '%s' (%lu)", request, 
strlen(request));
 
           // now we send a specific request via TR_DownloadURL() to
           // our update server
Index: src/BayesFilter.c
===================================================================
--- src/BayesFilter.c   (revision 2465)
+++ src/BayesFilter.c   (working copy)
@@ -523,7 +523,7 @@
     {
       TEXT buffer[40];
 
-      snprintf(buffer, sizeof(buffer), "%c %ld", word[0], (length / 10) * 10);
+      snprintf(buffer, sizeof(buffer), "%c %lu", word[0], (length / 10) * 10);
       tokenizerAdd(t, buffer, "skip", 1);
     }
   }
@@ -1020,7 +1020,7 @@
 
 /// lngamma_asymp()
 // truncated asymptotic series in 1/z
-INLINE double lngamma_asymp(double z)
+double lngamma_asymp(double z)
 {
   double w, w2, sum;
 
@@ -1102,7 +1102,7 @@
 ///
 /// lnPQfactoer()
 // log( e^(-x)*x^a/Gamma(a) )
-INLINE double lnPQfactor (double a, double x)
+double lnPQfactor (double a, double x)
 {
   int gsign;                // ignored because a > 0
   return a * log (x) - x - nsLnGamma (a, &gsign);
Index: src/YAM_UT.c
===================================================================
--- src/YAM_UT.c        (revision 2465)
+++ src/YAM_UT.c        (working copy)
@@ -1274,7 +1274,7 @@
       unsigned char c = (*read--)^CRYPTBYTE;
       int p = strlen(buffer);
 
-      snprintf(&buffer[p], sizeof(buffer)-p, "%03d ", c);
+      snprintf(&buffer[p], sizeof(buffer)-p, "%03u ", c);
    }
    return buffer;
 }
@@ -2967,7 +2967,7 @@
   Amiga2Date(seconds, &cd);
 
   // use snprintf to format the RFC2822 conforming datetime string.
-  snprintf(dst, dstlen, "%s, %02d %s %d %02d:%02d:%02d %+05d", wdays[cd.wday],
+  snprintf(dst, dstlen, "%s, %02u %s %u %02u:%02u:%02u %+05d", wdays[cd.wday],
                                                                cd.mday,
                                                                
months[cd.month-1],
                                                                cd.year,
@@ -5032,7 +5032,7 @@
   {
     struct ClockData cd;
     Amiga2Date(GetDateStamp(), &cd);
-    snprintf(filename, sizeof(filename), "YAM-%s%d.log", months[cd.month-1], 
cd.year);
+    snprintf(filename, sizeof(filename), "YAM-%s%u.log", months[cd.month-1], 
cd.year);
   }
   else
     strlcpy(filename, "YAM.log", sizeof(filename));
Index: src/YAM_COs.c
===================================================================
--- src/YAM_COs.c       (revision 2465)
+++ src/YAM_COs.c       (working copy)
@@ -1568,9 +1568,9 @@
          setcheckmark(gui->CH_SPAMMARKONMOVE, CE->SpamMarkOnMove);
          setcheckmark(gui->CH_SPAMABOOKISWHITELIST, 
CE->SpamAddressBookIsWhiteList);
          set(gui->NB_SPAMPROBTHRESHOLD, MUIA_Numeric_Value, 
CE->SpamProbabilityThreshold);
-         snprintf(buf, sizeof(buf), "%ld", 
BayesFilterNumberOfHamClassifiedMails());
+         snprintf(buf, sizeof(buf), "%lu", 
BayesFilterNumberOfHamClassifiedMails());
          set(gui->TX_SPAMGOODCOUNT, MUIA_Text_Contents, buf);
-         snprintf(buf, sizeof(buf), "%ld", 
BayesFilterNumberOfSpamClassifiedMails());
+         snprintf(buf, sizeof(buf), "%lu", 
BayesFilterNumberOfSpamClassifiedMails());
          set(gui->TX_SPAMBADCOUNT, MUIA_Text_Contents, buf);
       }
       break;

Other related posts: