return uctrl->udev;
}
-struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl)
+static struct udev_ctrl *udev_ctrl_ref(struct udev_ctrl *uctrl)
{
if (uctrl == NULL)
return NULL;
{
struct udev_ctrl_connection *conn;
struct ucred ucred;
- socklen_t slen;
const int on = 1;
+ int r;
- conn = calloc(1, sizeof(struct udev_ctrl_connection));
+ conn = new(struct udev_ctrl_connection, 1);
if (conn == NULL)
return NULL;
conn->refcount = 1;
}
/* check peer credential of connection */
- slen = sizeof(ucred);
- if (getsockopt(conn->sock, SOL_SOCKET, SO_PEERCRED, &ucred, &slen) < 0) {
- log_error("unable to receive credentials of ctrl connection: %m\n");
+ r = getpeercred(conn->sock, &ucred);
+ if (r < 0) {
+ log_error("unable to receive credentials of ctrl connection: %s", strerror(-r));
goto err;
}
if (ucred.uid > 0) {
udev_ctrl_connection_ref(conn);
/* wait for the incoming message */
- for(;;) {
+ for (;;) {
struct pollfd pfd[1];
int r;
return NULL;
}
-struct udev_ctrl_msg *udev_ctrl_msg_ref(struct udev_ctrl_msg *ctrl_msg)
-{
- if (ctrl_msg == NULL)
- return NULL;
- ctrl_msg->refcount++;
- return ctrl_msg;
-}
-
struct udev_ctrl_msg *udev_ctrl_msg_unref(struct udev_ctrl_msg *ctrl_msg)
{
if (ctrl_msg == NULL)