Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[coverity] Set of coverity fixes and removal of unused legacy code #96

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ AS_IF([test "x$enable_runlevel" != xno],
[AC_DEFINE([DSME_WANT_LIBRUNLEVEL], [1], [Enable runlevel plugin])])
AM_CONDITIONAL([WANT_RUNLEVEL], [test x$enable_runlevel != xno])

#
# upstart
#
AC_ARG_ENABLE([upstart],
[AS_HELP_STRING([--disable-upstart],
[disable upstart plugin (libupstart)])])

AS_IF([test "x$enable_upstart" != xno],
[AC_DEFINE([DSME_WANT_LIBUPSTART], [1])])
AM_CONDITIONAL([WANT_UPSTART], [test x$enable_upstart != xno])

#
# systemd
#
Expand Down
3 changes: 1 addition & 2 deletions dsme/dsme-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void usage(const char * progname)
fprintf(stderr, "Valid options:\n");
#ifdef DSME_LOG_ENABLE
fprintf(stderr, " -l --logging "
"Logging type (syslog, sti, stderr, stdout, none)\n");
"Logging type (syslog, stderr, stdout, none)\n");
fprintf(stderr, " -v --verbosity Log verbosity (3..7)\n");
#endif
#ifdef DSME_SYSTEMD_ENABLE
Expand Down Expand Up @@ -149,7 +149,6 @@ static void parse_options(int argc, /* in */
{
const char *log_method_name[] = {
"none", /* LOG_METHOD_NONE */
"sti", /* LOG_METHOD_STI */
"stdout", /* LOG_METHOD_STDOUT */
"stderr", /* LOG_METHOD_STDERR */
"syslog", /* LOG_METHOD_SYSLOG */
Expand Down
3 changes: 2 additions & 1 deletion dsme/dsme-wdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ static int daemonize(void)

i = open("/dev/null", O_RDWR);
i = open("/dev/console", O_RDWR);
if (dup(i) == -1) {
if (i > 0 && dup(i) == -1) {
fprintf(stderr, ME "daemonize: dup failed: %s\n", strerror(errno));
close(i);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Different indentation

return -1;
}

Expand Down
1 change: 0 additions & 1 deletion dsme/dsmesock.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ int dsmesock_listen(dsmesock_callback* read_and_queue)
g_io_channel_shutdown(as_chan, FALSE, 0);
g_io_channel_unref(as_chan);
as_chan = 0;
goto fail;

close_and_fail:
close(fd);
Expand Down
84 changes: 0 additions & 84 deletions dsme/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,59 +145,6 @@ static void log_to_null(int prio, const char* message)
{
}


/*
* This routine is used when STI logging method is set
*/
static void log_to_sti(int prio, const char* message)
{
if (logopt.sock != -1) {
if (logopt.verbosity >= prio) {
char buf[256];
int len;
struct nlmsghdr nlh;
struct sockaddr_nl snl;

if (prio >= 0) {
snprintf(buf,
sizeof(buf),
"%s %s: ",
logopt.prefix,
log_prio_str(prio));
}
len = strlen(buf);
snprintf(buf+len, sizeof(buf)-len, "%s", message);
len = strlen(buf);

struct iovec iov[2];
iov[0].iov_base = &nlh;
iov[0].iov_len = sizeof(struct nlmsghdr);
iov[1].iov_base = buf;
iov[1].iov_len = len;

struct msghdr msg;
msg.msg_name = (void *)&snl;
msg.msg_namelen = sizeof(struct sockaddr_nl);
msg.msg_iov = iov;
msg.msg_iovlen = sizeof(iov)/sizeof(*iov);
msg.msg_flags = 0;

memset(&snl, 0, sizeof(struct sockaddr_nl));

snl.nl_family = AF_NETLINK;
nlh.nlmsg_len = NLMSG_LENGTH(len);
nlh.nlmsg_type = (0xC0 << 8) | (1 << 0); /* STI Write */
nlh.nlmsg_flags = (logopt.channel << 8);

sendmsg(logopt.sock, &msg, 0);
}
} else {
fprintf(stderr, "dsme trace: ");
fprintf(stderr, "%s", message);
}
}


/*
* This routine is used when stdout logging method is set
*/
Expand Down Expand Up @@ -377,34 +324,6 @@ bool dsme_log_open(log_method method,
dsme_log_routine = log_to_null;
break;

case LOG_METHOD_STI:
{
struct sockaddr_nl snl;
int ret;

memset(&snl, 0, sizeof(struct sockaddr_nl));
snl.nl_family = AF_NETLINK;
snl.nl_pid = getpid();

logopt.sock = ret = socket(PF_NETLINK,
SOCK_RAW,
NETLINK_USERSOCK);
if (ret < 0)
goto out;

ret = bind(logopt.sock, (struct sockaddr *)&snl,
sizeof(struct sockaddr_nl));
if (ret < 0)
goto out;

logopt.channel = DSME_STI_CHANNEL;
dsme_log_routine = log_to_sti;
break;
out:
fprintf(stderr,
"STI init failed, will fall back to stderr method\n");
dsme_log_routine = log_to_stderr;
}
case LOG_METHOD_STDOUT:
dsme_log_routine = log_to_stdout;
break;
Expand Down Expand Up @@ -498,9 +417,6 @@ void dsme_log_close(void)
case LOG_METHOD_FILE:
fclose(logopt.filep);
break;
case LOG_METHOD_STI:
close(logopt.sock);
break;
default:
return;
}
Expand Down
1 change: 0 additions & 1 deletion include/dsme/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ extern "C" {
/* Logging methods */
typedef enum {
LOG_METHOD_NONE, /* Suppress all the messages */
LOG_METHOD_STI, /* Serial trace interface */
LOG_METHOD_STDOUT, /* Print messages to stdout */
LOG_METHOD_STDERR, /* Print messages to stderr */
LOG_METHOD_SYSLOG, /* Use syslog(3) */
Expand Down
10 changes: 0 additions & 10 deletions modules/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ if WANT_RUNLEVEL
pkglib_LTLIBRARIES += runlevel.la
endif

if WANT_UPSTART
pkglib_LTLIBRARIES += upstart.la
endif

if WANT_VALIDATOR_LISTENER
pkglib_LTLIBRARIES += validatorlistener.la
endif
Expand Down Expand Up @@ -99,12 +95,6 @@ if WANT_RUNLEVEL
runlevel_la_SOURCES = runlevel.c
endif

if WANT_UPSTART
upstart_la_SOURCES = upstart.c
upstart_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
upstart_la_LIBADD = $(DBUS_LIBS)
endif

if WANT_VALIDATOR_LISTENER
runlevel_la_SOURCES = validatorlistener.c
validatorlistener_la_CFLAGS = $(AM_CFLAGS) $(GLIB_CFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion modules/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static dsme_runlevel_t state2runlevel(dsme_state_t state)
case DSME_STATE_SHUTDOWN: runlevel = DSME_RUNLEVEL_SHUTDOWN; break;
case DSME_STATE_TEST: runlevel = DSME_RUNLEVEL_TEST; break;
case DSME_STATE_USER: runlevel = DSME_RUNLEVEL_USER; break;
case DSME_STATE_LOCAL: runlevel = DSME_RUNLEVEL_LOCAL;
case DSME_STATE_LOCAL: runlevel = DSME_RUNLEVEL_LOCAL; break;
case DSME_STATE_ACTDEAD: runlevel = DSME_RUNLEVEL_ACTDEAD; break;
case DSME_STATE_REBOOT: runlevel = DSME_RUNLEVEL_REBOOT; break;

Expand Down
Loading