Skip to content

Commit

Permalink
7698 SMF's bad_error() should be implemented in terms of uu_panic()
Browse files Browse the repository at this point in the history
Reviewed by: Igor Kozhukhov <igor@dilos.org>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Gordon Ross <gordon.w.ross@gmail.com>
  • Loading branch information
bcantrill authored and rmustacc committed Jan 5, 2017
1 parent 01ed526 commit 54d0224
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 53 deletions.
13 changes: 6 additions & 7 deletions usr/src/cmd/svc/configd/configd.h
Expand Up @@ -24,6 +24,10 @@
* Use is subject to license terms.
*/

/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

#ifndef _CONFIGD_H
#define _CONFIGD_H

Expand Down Expand Up @@ -88,14 +92,9 @@ extern "C" {

#define CONFIGD_CORE "core.%f.%t.%p"

#ifndef NDEBUG
#define bad_error(f, e) \
uu_warn("%s:%d: %s() returned bad error %d. Aborting.\n", \
__FILE__, __LINE__, f, e); \
abort()
#else
#define bad_error(f, e) abort()
#endif
uu_panic("%s:%d: %s() returned bad error %d. Aborting.\n", \
__FILE__, __LINE__, f, e);

typedef enum backend_type {
BACKEND_TYPE_NORMAL = 0,
Expand Down
15 changes: 4 additions & 11 deletions usr/src/cmd/svc/startd/startd.h
Expand Up @@ -21,7 +21,7 @@

/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, Joyent, Inc. All rights reserved.
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

#ifndef _STARTD_H
Expand Down Expand Up @@ -82,16 +82,9 @@ extern "C" {

#endif

#ifndef NDEBUG
#define bad_error(func, err) { \
(void) fprintf(stderr, "%s:%d: %s() failed with unexpected " \
"error %d. Aborting.\n", __FILE__, __LINE__, (func), (err)); \
abort(); \
}
#else
#define bad_error(func, err) abort()
#endif

#define bad_error(func, err) \
uu_panic("%s:%d: %s() failed with unexpected " \
"error %d. Aborting.\n", __FILE__, __LINE__, (func), (err));

#define min(a, b) (((a) < (b)) ? (a) : (b))

Expand Down
15 changes: 4 additions & 11 deletions usr/src/cmd/svc/svcadm/svcadm.c
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright 2013, Joyent, Inc. All rights reserved.
* Copyright 2015, Joyent, Inc. All rights reserved.
*/

/*
Expand Down Expand Up @@ -71,16 +71,9 @@
*/
#define WAIT_INTERVAL 3

#ifndef NDEBUG
#define bad_error(func, err) { \
pr_warn("%s:%d: %s() failed with unexpected error %d.\n", \
__FILE__, __LINE__, (func), (err)); \
abort(); \
}
#else
#define bad_error(func, err) abort()
#endif

#define bad_error(func, err) \
uu_panic("%s:%d: %s() failed with unexpected error %d.\n", \
__FILE__, __LINE__, (func), (err));

struct ht_elt {
struct ht_elt *next;
Expand Down
13 changes: 4 additions & 9 deletions usr/src/cmd/svc/svccfg/svccfg.h
Expand Up @@ -21,6 +21,7 @@

/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

#ifndef _CMD_SVCCFG_H
Expand Down Expand Up @@ -319,15 +320,9 @@ typedef struct scf_callback {
*/
typedef struct tmpl_errors tmpl_errors_t;

#ifndef NDEBUG
#define bad_error(func, err) { \
(void) fprintf(stderr, "%s:%d: %s() failed with unexpected " \
"error %d. Aborting.\n", __FILE__, __LINE__, (func), (err)); \
abort(); \
}
#else
#define bad_error(func, err) abort()
#endif
#define bad_error(func, err) \
uu_panic("%s:%d: %s() failed with unexpected " \
"error %d. Aborting.\n", __FILE__, __LINE__, (func), (err));

#define SC_CMD_LINE 0x0
#define SC_CMD_FILE 0x1
Expand Down
12 changes: 3 additions & 9 deletions usr/src/cmd/svc/svcs/explain.c
Expand Up @@ -22,7 +22,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

/*
Expand Down Expand Up @@ -112,15 +112,9 @@

#define uu_list_append(lst, e) uu_list_insert_before(lst, NULL, e)

#ifdef NDEBUG
#define bad_error(func, err) abort()
#else
#define bad_error(func, err) \
(void) fprintf(stderr, "%s:%d: %s() failed with unknown error %d.\n", \
__FILE__, __LINE__, func, err); \
abort();
#endif

uu_panic("%s:%d: %s() failed with unknown error %d.\n", \
__FILE__, __LINE__, func, err);

typedef struct {
const char *svcname;
Expand Down
3 changes: 3 additions & 0 deletions usr/src/lib/libuutil/common/libuutil.h
Expand Up @@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

#ifndef _LIBUUTIL_H
Expand Down Expand Up @@ -90,6 +91,8 @@ extern void uu_vdie(const char *, va_list) __NORETURN;
/*PRINTFLIKE2*/
extern void uu_xdie(int, const char *, ...) __NORETURN;
extern void uu_vxdie(int, const char *, va_list) __NORETURN;
/*PRINTFLIKE1*/
extern void uu_panic(const char *, ...) __NORETURN;

/*
* Exit status functions (not to be used directly)
Expand Down
10 changes: 4 additions & 6 deletions usr/src/lib/libuutil/common/libuutil_impl.h
Expand Up @@ -24,11 +24,13 @@
* Use is subject to license terms.
*/

/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
*/

#ifndef _LIBUUTIL_IMPL_H
#define _LIBUUTIL_IMPL_H

#pragma ident "%Z%%M% %I% %E% SMI"

#include <libuutil.h>
#include <pthread.h>

Expand All @@ -42,10 +44,6 @@ extern "C" {
void uu_set_error(uint_t);
#pragma rarely_called(uu_set_error)

/*PRINTFLIKE1*/
void uu_panic(const char *format, ...);
#pragma rarely_called(uu_panic)

struct uu_dprintf {
char *uud_name;
uu_dprintf_severity_t uud_severity;
Expand Down
2 changes: 2 additions & 0 deletions usr/src/lib/libuutil/common/mapfile-vers
Expand Up @@ -20,6 +20,7 @@
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2015, Joyent, Inc. All rights reserved.
#

#
Expand Down Expand Up @@ -101,6 +102,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
uu_memdup;
uu_msprintf;
uu_open_tmp;
uu_panic;
uu_setpname;
uu_strbw;
uu_strcaseeq;
Expand Down

0 comments on commit 54d0224

Please sign in to comment.