diff mbox series

conf_init_file: Fixed warn_unused_result error

Message ID 20231205192924.99320-1-steved@redhat.com (mailing list archive)
State New, archived
Headers show
Series conf_init_file: Fixed warn_unused_result error | expand

Commit Message

Steve Dickson Dec. 5, 2023, 7:29 p.m. UTC
conffile.c: In function 'conf_init_file':
conffile.c:776:17: error: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Werror=unused-result]
  776 |                 asprintf(&usrconf, "/usr%s", conf_file);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 support/nfs/conffile.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/support/nfs/conffile.c b/support/nfs/conffile.c
index 884eca9..1e9c22b 100644
--- a/support/nfs/conffile.c
+++ b/support/nfs/conffile.c
@@ -754,6 +754,7 @@  void
 conf_init_file(const char *conf_file)
 {
 	unsigned int i;
+	int j;
 
 	for (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++)
 		LIST_INIT (&conf_bindings[i]);
@@ -773,8 +774,8 @@  conf_init_file(const char *conf_file)
 	if (strncmp(conf_file, "/etc/", 5) == 0) {
 		char *usrconf = NULL;
 
-		asprintf(&usrconf, "/usr%s", conf_file);
-		if (usrconf) {
+		j = asprintf(&usrconf, "/usr%s", conf_file);
+		if (usrconf && j > 0) {
 			conf_load_file(usrconf);
 			conf_init_dir(usrconf);
 			free(usrconf);