slang-devel mailing list

[2021 Date Index] [2021 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-devel] Avoid compilation warning on uninitialized return variable


Dear S-Lang developers,

When compiling the slgdbm module, the following warning is emitted:

     gdbm-module.c: In function ‘slgdbm_store’:
 gdbm-module.c:138:11: warning: ‘ret’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   138 |    return ret;
       |           ^~~

The patch attached to this message avoids this warning. It assumes that when the gdbm_store function of libgdbm is not called, then this is considered an error. This assumption may be wrong.

This patch is currently being applied to the debian slang-gdbm package.

Best,

Rafael Laboissière
Description: Do not return a unitialized value in slgdbm_store
 Assume that, when the gdbm_store function is not executed, then there
 is an error and return the value -1. According to the libgdm
 documentation, the value -1 indicates that “an error occurred which
 prevented the item from being stored in the database.”
Author: Rafael Laboissière <rafael@xxxxxxxxxx>
Forwarded: no
Last-Update: 2021-12-02

--- slgdbm-1.7.1.orig/gdbm-module.c
+++ slgdbm-1.7.1/gdbm-module.c
@@ -118,7 +118,7 @@ static int slgdbm_store(char *key, char
 {
    GDBM_Type *p;
    SLang_MMT_Type *mmt;
-   int ret;
+   int ret = -1;
    datum k,v;
    k.dptr=key;
    k.dsize=strlen(key);

[2021 date index] [2021 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]