Skip to content

Commit

Permalink
Merge pull request #33 from ssahani/tiny_cleanup
Browse files Browse the repository at this point in the history
Introduce github CI and cleanups
  • Loading branch information
ssahani authored May 13, 2022
2 parents 0b8ed18 + daeb2a9 commit 4977106
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 30 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: systemd-netlogd CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: update
run: sudo apt-get update
- name: install python
run: sudo apt-get install python3 python3-pip python3-dev python3-setuptools build-essential meson ninja-build sphinx-doc sphinx-common python-configparser
- name: install build essentials
run: sudo apt-get install -y ninja-build glib-2.0-dev libudev-dev libyaml-dev libsystemd-dev clang gperf libcap-dev build-essential
- name: build
run: make
9 changes: 0 additions & 9 deletions .lgtm.yml

This file was deleted.

17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

4 changes: 1 addition & 3 deletions src/netlog/netlog-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,6 @@ int manager_new(Manager **ret, const char *state_file, const char *cursor) {
if (r < 0)
return r;

*ret = m;
m = NULL;

*ret = TAKE_PTR(m);
return 0;
}
4 changes: 3 additions & 1 deletion src/netlog/netlog-network.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ int manager_open_network_socket(Manager *m) {
if (SYSLOG_TRANSMISSION_PROTOCOL_TCP == m->protocol) {
union sockaddr_union sa;
socklen_t salen;

switch (m->address.sockaddr.sa.sa_family) {
case AF_INET:
sa = (union sockaddr_union) {
Expand All @@ -228,6 +229,7 @@ int manager_open_network_socket(Manager *m) {
r = -EAFNOSUPPORT;
goto fail;
}

r = connect(m->socket, &m->address.sockaddr.sa, salen);
if (r < 0 && errno != EINPROGRESS) {
r = -errno;
Expand All @@ -239,7 +241,7 @@ int manager_open_network_socket(Manager *m) {
return r;
}

r = fd_nonblock(m->socket, 1);
r = fd_nonblock(m->socket, true);
if (r < 0)
goto fail;

Expand Down
11 changes: 11 additions & 0 deletions src/share/macro.h
Original file line number Diff line number Diff line change
Expand Up @@ -399,4 +399,15 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
} \
struct __useless_struct_to_allow_trailing_semicolon__

/* Takes inspiration from Rust's Option::take() method: reads and returns a pointer, but at the same time
* resets it to NULL. See: https://doc.rust-lang.org/std/option/enum.Option.html#method.take */
#define TAKE_PTR(ptr) \
({ \
typeof(ptr) *_pptr_ = &(ptr); \
typeof(ptr) _ptr_ = *_pptr_; \
*_pptr_ = NULL; \
_ptr_; \
})


#include "log.h"

0 comments on commit 4977106

Please sign in to comment.