aboutsummaryrefslogtreecommitdiff
path: root/tools/virtiofsd/fuse_signals.c
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dgilbert@redhat.com>2019-12-09 19:53:47 +0000
committerDr. David Alan Gilbert <dgilbert@redhat.com>2020-01-23 16:41:36 +0000
commit7387863d033e8028aa09a815736617a7c4490827 (patch)
tree82a8c5dc4298c99fb950bef908ccda357e5aa2a8 /tools/virtiofsd/fuse_signals.c
parenta3e23f325439a290c504d6bbc48c2e742149ecab (diff)
virtiofsd: Format imported files to qemu style
Mostly using a set like: indent -nut -i 4 -nlp -br -cs -ce --no-space-after-function-call-names file clang-format -style=file -i -- file clang-tidy -fix-errors -checks=readability-braces-around-statements file clang-format -style=file -i -- file With manual cleanups. The .clang-format used is below. Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed by: Aleksandar Markovic <amarkovic@wavecomp.com> Language: Cpp AlignAfterOpenBracket: Align AlignConsecutiveAssignments: false # although we like it, it creates churn AlignConsecutiveDeclarations: false AlignEscapedNewlinesLeft: true AlignOperands: true AlignTrailingComments: false # churn AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakAfterReturnType: None # AlwaysBreakAfterDefinitionReturnType is taken into account AlwaysBreakBeforeMultilineStrings: false BinPackArguments: true BinPackParameters: true BraceWrapping: AfterControlStatement: false AfterEnum: false AfterFunction: true AfterStruct: false AfterUnion: false BeforeElse: false IndentBraces: false BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BreakBeforeTernaryOperators: false BreakStringLiterals: true ColumnLimit: 80 ContinuationIndentWidth: 4 Cpp11BracedListStyle: false DerivePointerAlignment: false DisableFormat: false ForEachMacros: [ 'CPU_FOREACH', 'CPU_FOREACH_REVERSE', 'CPU_FOREACH_SAFE', 'IOMMU_NOTIFIER_FOREACH', 'QLIST_FOREACH', 'QLIST_FOREACH_ENTRY', 'QLIST_FOREACH_RCU', 'QLIST_FOREACH_SAFE', 'QLIST_FOREACH_SAFE_RCU', 'QSIMPLEQ_FOREACH', 'QSIMPLEQ_FOREACH_SAFE', 'QSLIST_FOREACH', 'QSLIST_FOREACH_SAFE', 'QTAILQ_FOREACH', 'QTAILQ_FOREACH_REVERSE', 'QTAILQ_FOREACH_SAFE', 'QTAILQ_RAW_FOREACH', 'RAMBLOCK_FOREACH' ] IncludeCategories: - Regex: '^"qemu/osdep.h' Priority: -3 - Regex: '^"(block|chardev|crypto|disas|exec|fpu|hw|io|libdecnumber|migration|monitor|net|qapi|qemu|qom|standard-headers|sysemu|ui)/' Priority: -2 - Regex: '^"(elf.h|qemu-common.h|glib-compat.h|qemu-io.h|trace-tcg.h)' Priority: -1 - Regex: '.*' Priority: 1 IncludeIsMainRegex: '$' IndentCaseLabels: false IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: false MacroBlockBegin: '.*_BEGIN$' # only PREC_BEGIN ? MacroBlockEnd: '.*_END$' MaxEmptyLinesToKeep: 2 PointerAlignment: Right ReflowComments: true SortIncludes: true SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInContainerLiterals: true SpacesInParentheses: false SpacesInSquareBrackets: false Standard: Auto UseTab: Never ... Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'tools/virtiofsd/fuse_signals.c')
-rw-r--r--tools/virtiofsd/fuse_signals.c118
1 files changed, 61 insertions, 57 deletions
diff --git a/tools/virtiofsd/fuse_signals.c b/tools/virtiofsd/fuse_signals.c
index 4271947bd4..19d6791cb9 100644
--- a/tools/virtiofsd/fuse_signals.c
+++ b/tools/virtiofsd/fuse_signals.c
@@ -1,91 +1,95 @@
/*
- FUSE: Filesystem in Userspace
- Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
-
- Utility functions for setting signal handlers.
-
- This program can be distributed under the terms of the GNU LGPLv2.
- See the file COPYING.LIB
-*/
+ * FUSE: Filesystem in Userspace
+ * Copyright (C) 2001-2007 Miklos Szeredi <miklos@szeredi.hu>
+ *
+ * Utility functions for setting signal handlers.
+ *
+ * This program can be distributed under the terms of the GNU LGPLv2.
+ * See the file COPYING.LIB
+ */
#include "config.h"
-#include "fuse_lowlevel.h"
#include "fuse_i.h"
+#include "fuse_lowlevel.h"
-#include <stdio.h>
-#include <string.h>
#include <signal.h>
+#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
static struct fuse_session *fuse_instance;
static void exit_handler(int sig)
{
- if (fuse_instance) {
- fuse_session_exit(fuse_instance);
- if(sig <= 0) {
- fuse_log(FUSE_LOG_ERR, "assertion error: signal value <= 0\n");
- abort();
- }
- fuse_instance->error = sig;
- }
+ if (fuse_instance) {
+ fuse_session_exit(fuse_instance);
+ if (sig <= 0) {
+ fuse_log(FUSE_LOG_ERR, "assertion error: signal value <= 0\n");
+ abort();
+ }
+ fuse_instance->error = sig;
+ }
}
static void do_nothing(int sig)
{
- (void) sig;
+ (void)sig;
}
static int set_one_signal_handler(int sig, void (*handler)(int), int remove)
{
- struct sigaction sa;
- struct sigaction old_sa;
+ struct sigaction sa;
+ struct sigaction old_sa;
- memset(&sa, 0, sizeof(struct sigaction));
- sa.sa_handler = remove ? SIG_DFL : handler;
- sigemptyset(&(sa.sa_mask));
- sa.sa_flags = 0;
+ memset(&sa, 0, sizeof(struct sigaction));
+ sa.sa_handler = remove ? SIG_DFL : handler;
+ sigemptyset(&(sa.sa_mask));
+ sa.sa_flags = 0;
- if (sigaction(sig, NULL, &old_sa) == -1) {
- perror("fuse: cannot get old signal handler");
- return -1;
- }
+ if (sigaction(sig, NULL, &old_sa) == -1) {
+ perror("fuse: cannot get old signal handler");
+ return -1;
+ }
- if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
- sigaction(sig, &sa, NULL) == -1) {
- perror("fuse: cannot set signal handler");
- return -1;
- }
- return 0;
+ if (old_sa.sa_handler == (remove ? handler : SIG_DFL) &&
+ sigaction(sig, &sa, NULL) == -1) {
+ perror("fuse: cannot set signal handler");
+ return -1;
+ }
+ return 0;
}
int fuse_set_signal_handlers(struct fuse_session *se)
{
- /* If we used SIG_IGN instead of the do_nothing function,
- then we would be unable to tell if we set SIG_IGN (and
- thus should reset to SIG_DFL in fuse_remove_signal_handlers)
- or if it was already set to SIG_IGN (and should be left
- untouched. */
- if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGINT, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 ||
- set_one_signal_handler(SIGPIPE, do_nothing, 0) == -1)
- return -1;
+ /*
+ * If we used SIG_IGN instead of the do_nothing function,
+ * then we would be unable to tell if we set SIG_IGN (and
+ * thus should reset to SIG_DFL in fuse_remove_signal_handlers)
+ * or if it was already set to SIG_IGN (and should be left
+ * untouched.
+ */
+ if (set_one_signal_handler(SIGHUP, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGINT, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGTERM, exit_handler, 0) == -1 ||
+ set_one_signal_handler(SIGPIPE, do_nothing, 0) == -1) {
+ return -1;
+ }
- fuse_instance = se;
- return 0;
+ fuse_instance = se;
+ return 0;
}
void fuse_remove_signal_handlers(struct fuse_session *se)
{
- if (fuse_instance != se)
- fuse_log(FUSE_LOG_ERR,
- "fuse: fuse_remove_signal_handlers: unknown session\n");
- else
- fuse_instance = NULL;
+ if (fuse_instance != se) {
+ fuse_log(FUSE_LOG_ERR,
+ "fuse: fuse_remove_signal_handlers: unknown session\n");
+ } else {
+ fuse_instance = NULL;
+ }
- set_one_signal_handler(SIGHUP, exit_handler, 1);
- set_one_signal_handler(SIGINT, exit_handler, 1);
- set_one_signal_handler(SIGTERM, exit_handler, 1);
- set_one_signal_handler(SIGPIPE, do_nothing, 1);
+ set_one_signal_handler(SIGHUP, exit_handler, 1);
+ set_one_signal_handler(SIGINT, exit_handler, 1);
+ set_one_signal_handler(SIGTERM, exit_handler, 1);
+ set_one_signal_handler(SIGPIPE, do_nothing, 1);
}