[PATCH] Fix Samba build

Andreas Schneider asn at samba.org
Wed Aug 9 06:42:31 UTC 2017


On Wednesday, 9 August 2017 07:47:40 CEST Andreas Schneider via samba-
technical wrote:
> Hi,
> 
> review and push much appreciated.

Here are more patches, it is probably only GCC 7.1 which complains, so 
backport them to 4.7 too.


	Andreas

-- 
Andreas Schneider                   GPG-ID: CC014E3D
Samba Team                             asn at samba.org
www.samba.org
-------------- next part --------------
From e330eeebcd8d4aedc4bb6b4c1d46399ccec202b4 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 9 Aug 2017 07:45:04 +0200
Subject: [PATCH 1/3] s4:samdb: Fix building Samba with -O3
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

gcc error: ‘result’ may be used uninitialized

This wont happen, because ldb will return and error, but the compiler
doesn't understand this.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source4/dsdb/samdb/ldb_modules/vlv_pagination.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source4/dsdb/samdb/ldb_modules/vlv_pagination.c b/source4/dsdb/samdb/ldb_modules/vlv_pagination.c
index 5b744e3c181..980177cb05e 100644
--- a/source4/dsdb/samdb/ldb_modules/vlv_pagination.c
+++ b/source4/dsdb/samdb/ldb_modules/vlv_pagination.c
@@ -436,7 +436,7 @@ static int vlv_results(struct vlv_context *ac)
 			     ac->store->num_entries - 1);
 
 		for (i = first_i; i <= last_i; i++) {
-			struct ldb_result *result;
+			struct ldb_result *result = NULL;
 			struct GUID *guid = &ac->store->results[i];
 
 			ret = vlv_search_by_dn_guid(ac->module, ac, &result, guid,
-- 
2.13.3


From 6cb1c43e712c1316a09924dbd0d7390b638c69d4 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 9 Aug 2017 08:23:29 +0200
Subject: [PATCH 2/3] s3:torture: Fix spoolss test to build with -O3

Initialize variables so that we do not get a build warning that they
might be used uninitilized.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source4/torture/rpc/spoolss.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c
index 4f3e6a8b210..f7663bb27cd 100644
--- a/source4/torture/rpc/spoolss.c
+++ b/source4/torture/rpc/spoolss.c
@@ -2668,8 +2668,8 @@ static bool test_EnumForms_find_one(struct torture_context *tctx,
 				    bool print_server,
 				    const char *form_name)
 {
-	union spoolss_FormInfo *info;
-	uint32_t count;
+	union spoolss_FormInfo *info = NULL;
+	uint32_t count = 0;
 	bool found = false;
 	int i;
 
@@ -5555,11 +5555,12 @@ static bool test_SetPrinterDataEx_values(struct torture_context *tctx,
 
 	for (i=0; i < ARRAY_SIZE(values); i++) {
 
-		enum winreg_Type type;
-		DATA_BLOB blob_in, blob_out;
+		enum winreg_Type type = REG_NONE;
+		DATA_BLOB blob_in = data_blob_null;
+		DATA_BLOB blob_out = data_blob_null;
 		uint32_t ecount;
 		struct spoolss_PrinterEnumValues *einfo;
-		uint32_t needed;
+		uint32_t needed = 0;
 
 		if (torture_setting_bool(tctx, "samba3", false)) {
 			char *q;
-- 
2.13.3


From e37f06463d6137ec31dd1d3913771d24e8259a7d Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Wed, 9 Aug 2017 08:37:38 +0200
Subject: [PATCH 3/3] s3:utils: Fix buffer size for snprintf and format string
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

GCC 7.1 produces an error:
‘snprintf’ output between 47 and 66 bytes into a destination of size 40

BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930

Signed-off-by: Andreas Schneider <asn at samba.org>
---
 source3/utils/status_profile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/utils/status_profile.c b/source3/utils/status_profile.c
index 109415d37fa..829e84cef1c 100644
--- a/source3/utils/status_profile.c
+++ b/source3/utils/status_profile.c
@@ -126,7 +126,7 @@ static uint64_t print_count_count_samples(
 
 		if (buf[0] == '\0') {
 			snprintf(buf, buflen,
-				"%s %ju/sec",
+				"%-40s %ju/sec",
 				name, (uintmax_t)(step / delta_sec));
 		} else {
 			printf("%-40s %s %ju/sec\n",
@@ -240,7 +240,7 @@ static uint64_t print_count_samples(
 	uint64_t delta_usec)
 {
 	uint64_t count = 0;
-	char buf[40] = { '\0', };
+	char buf[60] = { '\0', };
 
 	if (delta_usec == 0) {
 		return 0;
-- 
2.13.3



More information about the samba-technical mailing list