[monitoring-plugins] Make use of xasprintf instead of asprintf

Jan Wagner git at monitoring-plugins.org
Wed Jul 30 21:30:07 CEST 2014


 Module: monitoring-plugins
 Branch: master
 Commit: a143739ed286cf9ae003792dbb1ce26ce43f3312
 Author: Jan Wagner <waja at cyconet.org>
   Date: Wed Jul 30 14:53:07 2014 +0200
    URL: https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=a143739

Make use of xasprintf instead of asprintf
---
Closes #1278

---

 lib/utils_base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/utils_base.c b/lib/utils_base.c
index 3822bcf..4fb6375 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -477,7 +477,7 @@ void np_enable_state(char *keyname, int expected_data_version) {
 	this_state->state_data=NULL;
 
 	/* Calculate filename */
-	ret = asprintf(&temp_filename, "%s/%lu/%s/%s",
+	ret = xasprintf(&temp_filename, "%s/%lu/%s/%s",
 	    _np_state_calculate_location_prefix(), (unsigned long)geteuid(),
 	    this_monitoring_plugin->plugin_name, this_state->name);
 	if (ret < 0)
@@ -619,7 +619,7 @@ void np_state_write_string(time_t data_time, char *data_string) {
 	
 	/* If file doesn't currently exist, create directories */
 	if(access(this_monitoring_plugin->state->_filename,F_OK)!=0) {
-		result = asprintf(&directories, "%s", this_monitoring_plugin->state->_filename);
+		result = xasprintf(&directories, "%s", this_monitoring_plugin->state->_filename);
 		if(result < 0)
 			die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
 			    strerror(errno));
@@ -638,7 +638,7 @@ void np_state_write_string(time_t data_time, char *data_string) {
 		np_free(directories);
 	}
 
-	result = asprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename);
+	result = xasprintf(&temp_file,"%s.XXXXXX",this_monitoring_plugin->state->_filename);
 	if(result < 0)
 		die(STATE_UNKNOWN, _("Cannot allocate memory: %s"),
 		    strerror(errno));



More information about the Commits mailing list