samba-o3: fix -Werror=strict-overflow error in lib/ldb-samba/ldb_ildap module
authorJoe Guo <joeg@catalyst.net.nz>
Wed, 19 Dec 2018 01:25:12 +0000 (14:25 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 8 Mar 2019 00:42:18 +0000 (00:42 +0000)
samba-o3 test failed in ubuntu:16.04 docker container:

    ==> /home/samba/samba/samba-o3.stderr <==
    ../../lib/ldb-samba/ldb_ildap.c: In function ‘ildb_handle_request’:
    ../../lib/ldb-samba/ldb_ildap.c:535:2: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
      for (i = 0; i < n; i++) {
      ^
    ../../lib/ldb-samba/ldb_ildap.c:579:2: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
      for (i = 0; i < n; i++) {
      ^
    cc1: all warnings being treated as errors

Change type to mute errors.

Signed-off-by: Joe Guo <joeg@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/ldb-samba/ldb_ildap.c

index 1b9a25ea3a7bcd3762919e1d59597865ea21b692..2c32395db70f05477e2115d36d937594c7cbf3f4 100644 (file)
@@ -114,13 +114,13 @@ static void ildb_auto_done_callback(struct tevent_context *ev,
   convert a ldb_message structure to a list of ldap_mod structures
   ready for ildap_add() or ildap_modify()
 */
-static struct ldap_mod **ildb_msg_to_mods(void *mem_ctx, int *num_mods,
+static struct ldap_mod **ildb_msg_to_mods(void *mem_ctx, unsigned int *num_mods,
                                          const struct ldb_message *msg,
                                          int use_flags)
 {
        struct ldap_mod **mods;
        unsigned int i;
-       int n = 0;
+       unsigned int n = 0;
 
        /* allocate maximum number of elements needed */
        mods = talloc_array(mem_ctx, struct ldap_mod *, msg->num_elements+1);
@@ -504,7 +504,7 @@ static int ildb_add(struct ildb_context *ac)
        struct ldb_request *req = ac->req;
        struct ldap_message *msg;
        struct ldap_mod **mods;
-       int i,n;
+       unsigned int i,n;
 
        msg = new_ldap_message(req);
        if (msg == NULL) {
@@ -548,7 +548,7 @@ static int ildb_modify(struct ildb_context *ac)
        struct ldb_request *req = ac->req;
        struct ldap_message *msg;
        struct ldap_mod **mods;
-       int i,n;
+       unsigned int i,n;
 
        msg = new_ldap_message(req);
        if (msg == NULL) {