Skip to content
Permalink
Browse files
[systemd] Change systemd_control_service() return value and type
The systemd_control_service() function looks like it should return
a boolean success/failure, but it is returning integer zero on success
and integer one on failure - which is confusing.

Make it return gboolean value so that success is TRUE and failure FALSE.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed Nov 7, 2016
1 parent 4e7f970 commit 40463c7aade2053b2187795ec5e2e5b9863f692c
Showing with 15 additions and 14 deletions.
  1. +3 −4 src/usb_moded-appsync.c
  2. +9 −8 src/usb_moded-systemd.c
  3. +3 −2 src/usb_moded-systemd.h
@@ -262,9 +262,8 @@ int activate_sync(const char *mode)
if(data->systemd)
{
if(!systemd_control_service(data->name, SYSTEMD_START))
mark_active(data->name, 0);
else
goto error;
mark_active(data->name, 0);
}
else if(data->launch)
{
@@ -323,7 +322,7 @@ int activate_sync_post(const char *mode)
log_debug("launching post-enum-app %s\n", data->name);
if(data->systemd)
{
if(systemd_control_service(data->name, SYSTEMD_START))
if(!systemd_control_service(data->name, SYSTEMD_START))
goto error;
mark_active(data->name, 1);
}
@@ -445,7 +444,7 @@ static void appsync_stop_apps(int post)
if(data->systemd && data->state == APP_STATE_ACTIVE && data->post == post)
{
log_debug("stopping %s-enum-app %s", post ? "post" : "pre", data->name);
if(systemd_control_service(data->name, SYSTEMD_STOP))
if(!systemd_control_service(data->name, SYSTEMD_STOP))
log_debug("Failed to stop %s\n", data->name);
data->state = APP_STATE_DONTCARE;
}
@@ -1,19 +1,20 @@
/**
@file usb_moded-systemd.c
@file usb_moded-systemd.c
Copyright (C) 2013 Jolla oy. All rights reserved.
Copyright (C) 2013-2016 Jolla oy. All rights reserved.
@author: Philippe De Swert <philippe.deswert@jollamobile.com>
@author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
modify it under the terms of the Lesser GNU General Public License
version 2 as published by the Free Software Foundation.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the Lesser GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -57,13 +58,13 @@ static DBusConnection * get_systemd_dbus_connection(void)

// mode = replace
// method = StartUnit or StopUnit
int systemd_control_service(const char *name, const char *method)
gboolean systemd_control_service(const char *name, const char *method)
{

DBusConnection *bus;
DBusError error;
DBusMessage *msg = NULL, *reply = NULL;
int ret = 1;
gboolean ret = FALSE;
const char * replace = "replace";

dbus_error_init(&error);
@@ -88,7 +89,7 @@ int systemd_control_service(const char *name, const char *method)
if(reply)
{
dbus_message_unref(reply);
ret = 0;
ret = TRUE;
}
dbus_message_unref(msg);
}
@@ -1,8 +1,9 @@
/*
Copyright (C) 2013 Jolla Oy. All rights reserved.
Copyright (C) 2013-2016 Jolla Oy. All rights reserved.
author: Philippe De Swert <philippe.deswert@njollamobile.com>
author: Simo Piiroinen <simo.piiroinen@jollamobile.com>
This program is free software; you can redistribute it and/or
modify it under the terms of the Lesser GNU General Public License
@@ -22,4 +23,4 @@
#define SYSTEMD_STOP "StopUnit"
#define SYSTEMD_START "StartUnit"

int systemd_control_service(const char *name, const char *method);
gboolean systemd_control_service(const char *name, const char *method);

0 comments on commit 40463c7

Please sign in to comment.