Skip to content

Commit

Permalink
fix: fake-udev use error code to signal fail on sending message
Browse files Browse the repository at this point in the history
  • Loading branch information
ABeltramo committed Feb 4, 2024
1 parent f5e3cdb commit 0aba499
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fake-udev/fake-udev-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
constexpr int UDEV_EVENT_MODE = 2;
int main(int argc, char *argv[]) {
InputParser input(argc, argv);
int rc = -1;

if (input.cmdOptionExists("-h") || input.cmdOptionExists("--help")) {
std::cout << "Usage: fake-udev -m <base64 encoded message> [options]" << std::endl;
Expand Down Expand Up @@ -51,15 +52,16 @@ int main(int argc, char *argv[]) {
netlink_connection conn{};
if (connect(conn, domain, type, protocol, groups)) {
auto header = make_udev_header(msg, udev_subsystem, udev_devtype);
if (send_msgs(conn, {header, msg}))
if (send_msgs(conn, {header, msg})) {
std::cout << "Message sent" << std::endl;
rc = 0;
}
}

cleanup(conn);
return 0;
} else {
std::cout << "No messages to send, have you forgot to pass -m ?" << std::endl;
}

return -1;
return rc;
}

0 comments on commit 0aba499

Please sign in to comment.