Skip to content
This repository has been archived by the owner on Jun 9, 2022. It is now read-only.

Commit

Permalink
Return EXIT_FAILURE to indicate abnormal termination
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://svn.code.sf.net/p/cmusphinx/code/trunk/sphinxbase@12041 94700074-3cef-4d97-a70e-9c8c206c02f5
  • Loading branch information
mbait committed Nov 10, 2013
1 parent ccb185f commit bfacd64
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions include/sphinxbase/err.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#ifndef _WIN32_WCE
#include <errno.h>
#endif
Expand Down Expand Up @@ -82,36 +83,36 @@ extern "C" {
#define E_FATAL(...) \
do { \
err_msg(ERR_FATAL, FILELINE, __VA_ARGS__); \
exit(-1); \
exit(EXIT_FAILURE); \
} while (0)

/**
* Print error text; Call perror(""); exit(errno);
*/
#define E_FATAL_SYSTEM(fmt, ...) \
do { \
int local_errno = errno; \
#define E_FATAL_SYSTEM(fmt, ...) \
do { \
int local_errno = errno; \
char *err_fmt = (char *) malloc(strlen(": %s\n") + strlen(fmt) + 1); \
strcpy(err_fmt, fmt); \
strcat(err_fmt, ": %s\n"); \
err_msg(ERR_FATAL, FILELINE, err_fmt, \
##__VA_ARGS__, strerror(local_errno)); \
free(err_fmt); \
exit(local_errno); \
strcpy(err_fmt, fmt); \
strcat(err_fmt, ": %s\n"); \
err_msg(ERR_FATAL, FILELINE, err_fmt, \
##__VA_ARGS__, strerror(local_errno)); \
free(err_fmt); \
exit(local_errno); \
} while (0)

/**
* Print error text; Call perror("");
*/
#define E_ERROR_SYSTEM(fmt, ...) \
do { \
int local_errno = errno; \
#define E_ERROR_SYSTEM(fmt, ...) \
do { \
int local_errno = errno; \
char *err_fmt = (char *) malloc(strlen(": %s\n") + strlen(fmt) + 1); \
strcpy(err_fmt, fmt); \
strcat(err_fmt, ": %s\n"); \
err_msg(ERR_ERROR, FILELINE, err_fmt, \
##__VA_ARGS__, strerror(local_errno)); \
free(err_fmt); \
strcpy(err_fmt, fmt); \
strcat(err_fmt, ": %s\n"); \
err_msg(ERR_ERROR, FILELINE, err_fmt, \
##__VA_ARGS__, strerror(local_errno)); \
free(err_fmt); \
} while (0)

/**
Expand Down Expand Up @@ -183,7 +184,7 @@ typedef void (*err_cb_f)(void* user_data, err_lvl_t, const char *, ...);
* Sets function to output error messages. Use it to redirect the logging
* to your application. By default the handler which dumps messages to
* stderr is set.
*
*
* @param - callback to pass messages too.
*/
SPHINXBASE_EXPORT void
Expand Down

0 comments on commit bfacd64

Please sign in to comment.