char buffer[8 + LINE_MAX], p[11]; struct iovec iov[2];
- if (priority < 0 || priority > 7)
- return -EINVAL;
-
- if (!format)
- return -EINVAL;
+ assert_return(priority >= 0, -EINVAL);
+ assert_return(priority <= 7, -EINVAL);
+ assert_return(format, -EINVAL);
snprintf(p, sizeof(p), "PRIORITY=%i", priority & LOG_PRIMASK);
char_array_0(p);
return sd_journal_sendv(iov, 2);
}
-_printf_attr_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, int extra, struct iovec **_iov) {
+_printf_(1, 0) static int fill_iovec_sprintf(const char *format, va_list ap, int extra, struct iovec **_iov) {
PROTECT_ERRNO;
int r, n = 0, i = 0, j;
struct iovec *iov = NULL;
char path[] = "/dev/shm/journal.XXXXXX";
bool have_syslog_identifier = false;
- if (_unlikely_(!iov))
- return -EINVAL;
-
- if (_unlikely_(n <= 0))
- return -EINVAL;
+ assert_return(iov, -EINVAL);
+ assert_return(n > 0, -EINVAL);
w = alloca(sizeof(struct iovec) * n * 5 + 3);
l = alloca(sizeof(uint64_t) * n);
have_syslog_identifier = have_syslog_identifier ||
(c == (char *) iov[i].iov_base + 17 &&
- memcmp(iov[i].iov_base, "SYSLOG_IDENTIFIER", 17) == 0);
+ startswith(iov[i].iov_base, "SYSLOG_IDENTIFIER"));
nl = memchr(iov[i].iov_base, '\n', iov[i].iov_len);
if (nl) {
if (k >= 0)
return 0;
+ /* Fail silently if the journal is not available */
+ if (errno == ENOENT)
+ return 0;
+
if (errno != EMSGSIZE && errno != ENOBUFS)
return -errno;
size_t l;
ssize_t r;
- if (priority < 0 || priority > 7)
- return -EINVAL;
+ assert_return(priority >= 0, -EINVAL);
+ assert_return(priority <= 7, -EINVAL);
fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0);
if (fd < 0)
struct iovec iov[5];
char *f;
- if (priority < 0 || priority > 7)
- return -EINVAL;
-
- if (_unlikely_(!format))
- return -EINVAL;
+ assert_return(priority >= 0, -EINVAL);
+ assert_return(priority <= 7, -EINVAL);
+ assert_return(format, -EINVAL);
snprintf(p, sizeof(p), "PRIORITY=%i", priority & LOG_PRIMASK);
char_array_0(p);
struct iovec *niov;
char *f;
- if (_unlikely_(!iov))
- return -EINVAL;
-
- if (_unlikely_(n <= 0))
- return -EINVAL;
+ assert_return(iov, -EINVAL);
+ assert_return(n > 0, -EINVAL);
niov = alloca(sizeof(struct iovec) * (n + 3));
memcpy(niov, iov, sizeof(struct iovec) * n);