[PATCH] conf_init_file: Fixed warn_unused_result error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 support/nfs/conffile.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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);
-- 
2.41.0





[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux