Error message cleanup.

This commit is contained in:
Robert James Kaes committed 2001-09-07 04:21:07 +00:00
1 parent f5b9bdb93d
commit 1a9dc4e7e8
8 files changed
+85 -71

No files matched your search

+11 -11
View File
@@ -1,4 +1,4 @@
/* $Id: utils.c,v 1.8 2001-08-30 16:52:56 rjkaes Exp $
/* $Id: utils.c,v 1.9 2001-09-07 04:21:07 rjkaes Exp $
*
* Misc. routines which are used by the various functions to handle strings
* and memory allocation and pretty much anything else we can think of. Also,
@@ -62,13 +62,13 @@ int httperr(struct conn_s *connptr, int err, const char *msg)
header_buffer = malloc(HEADER_SIZE);
if (!header_buffer) {
log_message(LOG_CRIT, "Out of memory!");
log_message(LOG_ERR, "Could not allocate memory.");
return -1;
}
message_buffer = malloc(MAXBUFFSIZE);
if (!message_buffer) {
log_message(LOG_CRIT, "Out of memory!");
log_message(LOG_ERR, "Could not allocate memory.");
safefree(header_buffer);
return -1;
}
@@ -82,7 +82,7 @@ int httperr(struct conn_s *connptr, int err, const char *msg)
output_size = strlen(message_buffer) + strlen(header_buffer);
connptr->output_message = malloc(output_size + 1);
if (!connptr->output_message) {
log_message(LOG_CRIT, "Out of memory!");
log_message(LOG_ERR, "Could not allocate memory.");
safefree(header_buffer);
safefree(message_buffer);
return -1;
@@ -135,7 +135,7 @@ static int create_file_safely(const char *filename)
* existing", exit.
*/
if (errno != ENOENT) {
log_message(LOG_ERR, "Error checking PID file %s: %s",
log_message(LOG_ERR, "Error checking PID file %s: %s.",
filename, strerror(errno));
return -1;
}
@@ -146,7 +146,7 @@ static int create_file_safely(const char *filename)
* and open()
*/
if ((fildes = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) {
log_message(LOG_ERR, "Could not create PID file %s: %s",
log_message(LOG_ERR, "Could not create PID file %s: %s.",
filename, strerror(errno));
return -1;
}
@@ -157,7 +157,7 @@ static int create_file_safely(const char *filename)
* Open an existing file.
*/
if ((fildes = open(filename, O_RDWR)) < 0) {
log_message(LOG_ERR, "Could not open PID file %s: %s",
log_message(LOG_ERR, "Could not open PID file %s: %s.",
filename, strerror(errno));
return -1;
}
@@ -170,7 +170,7 @@ static int create_file_safely(const char *filename)
|| lstatinfo.st_mode != fstatinfo.st_mode
|| lstatinfo.st_ino != fstatinfo.st_ino
|| lstatinfo.st_dev != fstatinfo.st_dev) {
log_message(LOG_ERR, "The PID file %s has been changed before it could be opened!",
log_message(LOG_ERR, "The PID file %s has been changed before it could be opened.",
filename);
close(fildes);
return -1;
@@ -184,7 +184,7 @@ static int create_file_safely(const char *filename)
* st_mode check would also find this)
*/
if (fstatinfo.st_nlink > 1 || !S_ISREG(lstatinfo.st_mode)) {
log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s",
log_message(LOG_ERR, "The PID file %s has too many links, or is not a regular file: %s.",
filename, strerror(errno));
close(fildes);
return -1;
@@ -203,7 +203,7 @@ static int create_file_safely(const char *filename)
#else
close(fildes);
if ((fildes = open(filename, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) {
log_message(LOG_ERR, "Could not open PID file %s: %s",
log_message(LOG_ERR, "Could not open PID file %s: %s.",
filename, strerror(errno));
return -1;
}
@@ -231,7 +231,7 @@ void pidfile_create(const char *filename)
* Open a stdio file over the low-level one.
*/
if ((fd = fdopen(fildes, "w")) == NULL) {
log_message(LOG_ERR, "fdopen() error on PID file %s: %s",
log_message(LOG_ERR, "fdopen() error on PID file %s: %s.",
filename, strerror(errno));
close(fildes);
unlink(filename);