* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
+
+#include <stdlib.h>
+
#include <libsyscommon/log.h>
#include <system/syscommon-plugin-common.h>
EXPORT
int syscommon_plugin_sessiond_get_backend(int *backend_exists)
{
+ int ret = 0;
+ if (!backend_exists) {
+ _E("Invalid parameter: backend_exists is NULL");
+ return -EINVAL;
+ }
+
if (funcs)
goto get_backend_success;
- int ret = syscommon_plugin_common_get_backend(
+ funcs = calloc(1, sizeof *funcs);
+ if (!funcs) {
+ _E("Failed to allocate memory for funcs");
+ return -ENOMEM;
+ }
+
+ ret = syscommon_plugin_common_get_backend(
SYSCOMMON_PLUGIN_MODULE_SESSIOND,
(void **)&funcs);
- if (ret < 0) {
- if (ret == -ENOENT) {
- _I("sessiond backend was not found");
- if (backend_exists)
- *backend_exists = 0;
- return 0;
- }
-
- _E("Failed to get sessiond backend: %d", ret);
- return ret;
+ if (ret == -ENOENT) {
+ _I("sessiond plugin backend was not found");
+ ret = 0;
+ *backend_exists = 0;
+ goto get_backend_failure;
+ } else if (ret < 0) {
+ _E("Failed to get sessiond plugin backend: %d", ret);
+ goto get_backend_failure;
}
_I("Success to get sessiond backend: %d", ret);
get_backend_success:
- if (backend_exists)
- *backend_exists = 1;
+ *backend_exists = 1;
return 0;
+
+get_backend_failure:
+ free(funcs);
+ funcs = NULL;
+
+ return ret;
}
EXPORT
_E("Failed to put sessiond backend: %d", ret);
return ret;
}
- funcs = NULL;
_I("Success to put sessiond backend: %d", ret);
+ free(funcs);
+ funcs = NULL;
+
return 0;
}