static void help(void) {
- pager_open(arg_no_pager, arg_pager_end);
+ (void) pager_open(arg_no_pager, arg_pager_end);
printf("%s [OPTIONS...] [MATCHES...]\n\n"
"Query the journal.\n\n"
assert(argc >= 0);
assert(argv);
- while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:c:S:U:t:u:NF:xrM:", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "hefo:aln::qmb::kD:p:g:c:S:U:t:u:NF:xrM:", options, NULL)) >= 0)
switch (c) {
if (!v)
return log_oom();
- if (!arg_output_fields) {
- arg_output_fields = v;
- v = NULL;
- } else {
+ if (!arg_output_fields)
+ arg_output_fields = TAKE_PTR(v);
+ else {
r = strv_extend_strv(&arg_output_fields, v, true);
if (r < 0)
return log_oom();
return -EINVAL;
}
- if (!strv_isempty(arg_system_units) && (arg_journal_type == SD_JOURNAL_CURRENT_USER)) {
-
+ if (!strv_isempty(arg_system_units) && arg_journal_type == SD_JOURNAL_CURRENT_USER) {
/* Specifying --user and --unit= at the same time makes no sense (as the former excludes the user
* journal, but the latter excludes the system journal, thus resulting in empty output). Let's be nice
* to users, and automatically turn --unit= into --user-unit= if combined with --user. */
_cleanup_free_ char *p = NULL, *t = NULL, *t2 = NULL, *interpreter = NULL;
struct stat st;
- r = chase_symlinks(*i, NULL, 0, &p);
+ r = chase_symlinks(*i, NULL, CHASE_TRAIL_SLASH, &p);
if (r < 0)
return log_error_errno(r, "Couldn't canonicalize path: %m");
if (r < 0)
return r;
- *ret = next_boot;
- next_boot = NULL;
+ *ret = TAKE_PTR(next_boot);
return 0;
}
}
}
LIST_INSERT_AFTER(boot_list, head, tail, current);
- tail = current;
- current = NULL;
+ tail = TAKE_PTR(current);
count++;
}
}
if (count == 0)
return count;
- pager_open(arg_no_pager, arg_pager_end);
+ (void) pager_open(arg_no_pager, arg_pager_end);
/* numbers are one less, but we need an extra char for the sign */
w = DECIMAL_STR_WIDTH(count - 1) + 1;
}
}
- *units = found;
- found = NULL;
+ *units = TAKE_PTR(found);
+
return 0;
}
STRV_FOREACH(i, arg_system_units) {
_cleanup_free_ char *u = NULL;
- r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u);
+ r = unit_name_mangle(*i, UNIT_NAME_MANGLE_GLOB | (arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN), &u);
if (r < 0)
return r;
STRV_FOREACH(i, arg_user_units) {
_cleanup_free_ char *u = NULL;
- r = unit_name_mangle(*i, UNIT_NAME_GLOB, &u);
+ r = unit_name_mangle(*i, UNIT_NAME_MANGLE_GLOB | (arg_quiet ? 0 : UNIT_NAME_MANGLE_WARN), &u);
if (r < 0)
return r;
} else {
bool oneline = arg_action == ACTION_LIST_CATALOG;
- pager_open(arg_no_pager, arg_pager_end);
+ (void) pager_open(arg_no_pager, arg_pager_end);
if (optind < argc)
r = catalog_list_items(stdout, database, oneline, argv + optind);
goto finish;
}
- r = journal_access_check_and_warn(j, arg_quiet);
+ r = journal_access_check_and_warn(j, arg_quiet,
+ !(arg_journal_type == SD_JOURNAL_CURRENT_USER || arg_user_units));
if (r < 0)
goto finish;
need_seek = true;
if (!arg_follow)
- pager_open(arg_no_pager, arg_pager_end);
+ (void) pager_open(arg_no_pager, arg_pager_end);
if (!arg_quiet && (arg_lines != 0 || arg_follow)) {
usec_t start, end;
goto finish;
n_shown++;
-
- /* If journalctl take a long time to process messages, and
- * during that time journal file rotation occurs, a journalctl
- * client will keep those rotated files open until it calls
- * sd_journal_process(), which typically happens as a result
- * of calling sd_journal_wait() below in the "following" case.
- * By periodically calling sd_journal_process() during the
- * processing loop we shrink the window of time a client
- * instance has open file descriptors for rotated (deleted)
- * journal files.
- *
- * FIXME: This change does not appear to solve the case of a
- * "paused" output stream. If somebody is using `journalctl | less`
- * and pauses the output, then without a background thread
- * periodically listening for inotify delete events and cleaning
- * up, journal logs will eventually stop flowing in cases where
- * a journal client with enough open files causes the "free"
- * disk space threshold to be crossed.
- */
+
+ /* If journalctl take a long time to process messages, and during that time journal file
+ * rotation occurs, a journalctl client will keep those rotated files open until it calls
+ * sd_journal_process(), which typically happens as a result of calling sd_journal_wait() below
+ * in the "following" case. By periodically calling sd_journal_process() during the processing
+ * loop we shrink the window of time a client instance has open file descriptors for rotated
+ * (deleted) journal files. */
if ((n_shown % PROCESS_INOTIFY_INTERVAL) == 0) {
r = sd_journal_process(j);
if (r < 0) {