Re: [SSSD] Unpleasant warnings
I can see only two warnings: On Fri, Sep 04, 2009 at 07:32:40PM -0400, Dmitri Pal wrote: Steve, I ran a build today and saw some unpleasant warnings especially about the uninitialized variables. ../../server/providers/ldap/sdap_async.c: In function 'sdap_get_users_save_done': ../../server/providers/ldap/sdap_async.c:1427: warning: 'timestamp' may be used uninitialized in this function Although the code takes care that timestamp is properly initialized I've add a '= NULL' to suppress the warning. ../../server/db/sysdb.c: In function ‘sysdb_init’: ../../server/db/sysdb.c:597: warning: ‘path’ may be used uninitialized in this function ../../server/tools/sss_useradd.c: In function ‘main’: ../../server/tools/sss_useradd.c:386: warning: assignment discards qualifiers from pointer target type ../../server/tools/sss_useradd.c:424: warning: ‘ret’ is used uninitialized in this function ../../server/tools/sss_usermod.c: In function ‘main’: ../../server/tools/sss_usermod.c:437: warning: assignment discards qualifiers from pointer target type ../../server/tools/sss_groupmod.c: In function ‘main’: ../../server/tools/sss_groupmod.c:373: warning: assignment discards qualifiers from pointer target type ../../server/responder/nss/nsssrv_cmd.c: In function ‘fill_grent’: ../../server/responder/nss/nsssrv_cmd.c:1371: warning: ‘i’ may be used uninitialized in this function The value of count might have an unexpected value, but in this case fill_grent will return an error, too. I cannot see the other warnings, what compiler options and code revision are you using? bye, Sumit From 08b9b713d3da341c161b1bd6505d9f3968b84f6b Mon Sep 17 00:00:00 2001 From: Sumit Bose sb...@redhat.com Date: Tue, 8 Sep 2009 12:08:39 +0200 Subject: [PATCH] fix two possible uninitialized values --- server/providers/ldap/sdap_async.c |2 +- server/responder/nss/nsssrv_cmd.c |3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/server/providers/ldap/sdap_async.c b/server/providers/ldap/sdap_async.c index e13fba3..550cb9d 100644 --- a/server/providers/ldap/sdap_async.c +++ b/server/providers/ldap/sdap_async.c @@ -1424,7 +1424,7 @@ static void sdap_get_users_save_done(struct tevent_req *subreq) struct tevent_req); struct sdap_get_users_state *state = tevent_req_data(req, struct sdap_get_users_state); -char *timestamp; +char *timestamp = NULL; int ret; ret = sdap_save_user_recv(subreq, state, timestamp); diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index 88749e9..6bbfede 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -1368,7 +1368,8 @@ static int fill_grent(struct sss_packet *packet, size_t nsize; size_t delim; size_t dom_len; -int i, ret, num, memnum; +int i = 0; +int ret, num, memnum; size_t rzero, rsize; bool add_domain = dom-fqnames; const char *domain = dom-name; -- 1.6.2.5 ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel
Re: [SSSD] Unpleasant warnings
On Tue, 2009-09-08 at 12:21 +0200, Sumit Bose wrote: ../../server/responder/nss/nsssrv_cmd.c: In function ‘fill_grent’: ../../server/responder/nss/nsssrv_cmd.c:1371: warning: ‘i’ may be used uninitialized in this function The value of count might have an unexpected value, but in this case fill_grent will return an error, too. Yet this is bad, as the function is supposed to always return how many entries have been used, even in case of errors. Attached a patch to fix this, that makes it explicit. Simo. -- Simo Sorce * Red Hat, Inc * New York From 639f2883ed24668ccd09ecda6d7c7decf19cce81 Mon Sep 17 00:00:00 2001 From: Simo Sorce sso...@redhat.com Date: Tue, 8 Sep 2009 14:36:11 -0400 Subject: [PATCH] Make counter for used messages explicit. --- server/responder/nss/nsssrv_cmd.c |7 --- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/server/responder/nss/nsssrv_cmd.c b/server/responder/nss/nsssrv_cmd.c index 5b73be0..405dae8 100644 --- a/server/responder/nss/nsssrv_cmd.c +++ b/server/responder/nss/nsssrv_cmd.c @@ -1434,7 +1434,7 @@ static int fill_grent(struct sss_packet *packet, size_t nsize; size_t delim; size_t dom_len; -int i, ret, num, memnum; +int i, ret, num, memnum, used; size_t rzero, rsize; bool add_domain = dom-fqnames; const char *domain = dom-name; @@ -1450,6 +1450,7 @@ static int fill_grent(struct sss_packet *packet, num = 0; memnum = 0; +used = 0; /* first 2 fields (len and reserved), filled up later */ ret = sss_packet_grow(packet, 2*sizeof(uint32_t)); @@ -1460,7 +1461,7 @@ static int fill_grent(struct sss_packet *packet, rzero = 2*sizeof(uint32_t); rsize = 0; -for (i = 0; i *count; i++) { +for (i = 0; i *count; i++, used++) { msg = msgs[i]; /* new group */ @@ -1673,7 +1674,7 @@ static int fill_grent(struct sss_packet *packet, } done: -*count = i; +*count = used; if (num == 0) { /* if num is 0 most probably something went wrong, -- 1.6.2.5 ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel
Re: [SSSD] Unpleasant warnings
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/08/2009 06:21 AM, Sumit Bose wrote: I can see only two warnings: On Fri, Sep 04, 2009 at 07:32:40PM -0400, Dmitri Pal wrote: Steve, I ran a build today and saw some unpleasant warnings especially about the uninitialized variables. ../../server/providers/ldap/sdap_async.c: In function 'sdap_get_users_save_done': ../../server/providers/ldap/sdap_async.c:1427: warning: 'timestamp' may be used uninitialized in this function Although the code takes care that timestamp is properly initialized I've add a '= NULL' to suppress the warning. ../../server/db/sysdb.c: In function ?sysdb_init?: ../../server/db/sysdb.c:597: warning: ?path? may be used uninitialized in this function ../../server/tools/sss_useradd.c: In function ?main?: ../../server/tools/sss_useradd.c:386: warning: assignment discards qualifiers from pointer target type ../../server/tools/sss_useradd.c:424: warning: ?ret? is used uninitialized in this function ../../server/tools/sss_usermod.c: In function ?main?: ../../server/tools/sss_usermod.c:437: warning: assignment discards qualifiers from pointer target type ../../server/tools/sss_groupmod.c: In function ?main?: ../../server/tools/sss_groupmod.c:373: warning: assignment discards qualifiers from pointer target type ../../server/responder/nss/nsssrv_cmd.c: In function ?fill_grent?: ../../server/responder/nss/nsssrv_cmd.c:1371: warning: ?i? may be used uninitialized in this function The value of count might have an unexpected value, but in this case fill_grent will return an error, too. I cannot see the other warnings, what compiler options and code revision are you using? bye, Sumit Ack - -- Stephen Gallagher RHCE 804006346421761 Looking to carve out IT costs? www.redhat.com/carveoutcosts/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAkqmqeAACgkQeiVVYja6o6NvMQCeIM8QokUrVPn9aw1Z1hfsaib9 Ev4An0Zp9KV88+YQEy84Utwi96hTEo1k =bIzx -END PGP SIGNATURE- ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel
Re: [SSSD] Unpleasant warnings
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 09/08/2009 03:01 PM, Stephen Gallagher wrote: On 09/08/2009 02:36 PM, Simo Sorce wrote: On Tue, 2009-09-08 at 12:21 +0200, Sumit Bose wrote: ../../server/responder/nss/nsssrv_cmd.c: In function fill_grent: ../../server/responder/nss/nsssrv_cmd.c:1371: warning: i may be used uninitialized in this function The value of count might have an unexpected value, but in this case fill_grent will return an error, too. Yet this is bad, as the function is supposed to always return how many entries have been used, even in case of errors. Attached a patch to fix this, that makes it explicit. Simo. ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel Ack Merged Sumit's fix for the sdap timestamp = NULL into this patch and pushed. (Replied to the wrong message the first time) ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel - -- Stephen Gallagher RHCE 804006346421761 Looking to carve out IT costs? www.redhat.com/carveoutcosts/ -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/ iEYEARECAAYFAkqmrMgACgkQeiVVYja6o6OVTgCfcAMS2GtEc8V93U23QWmaUX7h UbwAn1cNk2jqlVVZDTEmQt0a8gfv/EDV =UpXR -END PGP SIGNATURE- ___ sssd-devel mailing list sssd-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/sssd-devel