int r;
sd_bus_message *msg;
struct app_data *app = (struct app_data *)userdata;
+ char err[512];
assert(app);
assert(app->bus);
}
if (NULL != ret_error && 0 != sd_bus_error_is_set(ret_error)) {
- fprintf(stderr,
- "Failed to add match callback: %s/%s (%s)\n",
- ret_error->name,
- ret_error->message,
- strerror(sd_bus_error_get_errno(ret_error)));
+ if (strerror_r(abs(sd_bus_error_get_errno(ret_error)), err, sizeof err))
+ fprintf(stderr,
+ "Failed to add match callback: %s/%s (%s)\n",
+ ret_error->name,
+ ret_error->message,
+ err);
app->state = APP_STATE_FINISHED_ERROR;
sd_event_exit(app->event, sd_bus_error_get_errno(ret_error));
return 0;
"SystemdAsyncMatchTestSignal");
if (r < 0) {
- fprintf(stderr, "Failed to add signal: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to add signal: %s\n", err);
app->state = APP_STATE_FINISHED_ERROR;
sd_event_exit(app->event, r);
return r;
r = sd_bus_send(app->bus, msg, NULL);
if (r < 0) {
- fprintf(stderr, "Failed to emit signal: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to emit signal: %s\n", err);
app->state = APP_STATE_FINISHED_ERROR;
sd_event_exit(app->event, r);
return r;
int r;
sigset_t ss;
uint64_t now;
+ char err[512];
const char *match = "type='signal',interface='org.freedesktop.systemd1.Manager',path='/org/freedesktop/systemd1',member='SystemdAsyncMatchTestSignal'";
r = sd_event_default(&app.event);
/* Connect to the system bus */
r = sd_bus_open_system(&app.bus);
if (r < 0) {
- fprintf(stderr, "Failed to connect to system bus: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to connect to system bus: %s\n", err);
app.state = APP_STATE_FINISHED_ERROR;
goto finish;
}
/* Add global test timeout callback */
r = sd_event_now(app.event, CLOCK_MONOTONIC, &now);
if (r < 0) {
- fprintf(stderr, "Failed to get current timestamp: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to get current timestamp: %s\n", err);
app.state = APP_STATE_FINISHED_ERROR;
goto finish;
}
&app);
if (r < 0) {
- fprintf(stderr, "Failed to add global timeout: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to add global timeout: %s\n", err);
app.state = APP_STATE_FINISHED_ERROR;
goto finish;
}
r = sd_bus_add_match_async(app.bus, &slot, match, signal_match_callback,
install_match_callback, &app);
if (r < 0) {
- fprintf(stderr, "Failed to add match: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to add match: %s\n", err);
app.state = APP_STATE_FINISHED_ERROR;
goto finish;
}
/* Attach system bus events to manloop */
r = sd_bus_attach_event(app.bus, app.event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0) {
- fprintf(stderr, "Failed to attach system bus to mainloop: %s\n", strerror(-r));
+ if (strerror_r(abs(r), err, sizeof err))
+ fprintf(stderr, "Failed to attach system bus to mainloop: %s\n", err);
app.state = APP_STATE_FINISHED_ERROR;
goto finish;
}