summaryrefslogtreecommitdiff
path: root/epan/except.c
diff options
context:
space:
mode:
authorAlexis La Goutte <alexis.lagoutte@gmail.com>2014-01-26 18:24:45 +0000
committerAlexis La Goutte <alexis.lagoutte@gmail.com>2014-01-26 18:24:45 +0000
commitea227de9e2878b06ec754a1aabea972b05ca53da (patch)
tree93b8e2e054ff454966be28e1ab616438a5e66357 /epan/except.c
parentc6022b3b85dedeae9465e5bb2fe38fdb35f21ee9 (diff)
downloadwireshark-ea227de9e2878b06ec754a1aabea972b05ca53da.tar.gz
Fix indent (Use 4spaces) and modelines info
svn path=/trunk/; revision=54967
Diffstat (limited to 'epan/except.c')
-rw-r--r--epan/except.c171
1 files changed, 92 insertions, 79 deletions
diff --git a/epan/except.c b/epan/except.c
index 6695294666..5b2d846af1 100644
--- a/epan/except.c
+++ b/epan/except.c
@@ -43,7 +43,7 @@
#include "exceptions.h"
#endif
-#define XCEPT_BUFFER_SIZE 1024
+#define XCEPT_BUFFER_SIZE 1024
#ifdef KAZLIB_POSIX_THREADS
@@ -90,23 +90,23 @@ int except_init(void)
assert (init_counter < INT_MAX);
if (init_counter++ == 0) {
- int top_ok = (pthread_key_create(&top_key, 0) == 0);
- int uh_ok = (pthread_key_create(&uh_key, 0) == 0);
- int alloc_ok = (pthread_key_create(&alloc_key, 0) == 0);
- int dealloc_ok = (pthread_key_create(&dealloc_key, 0) == 0);
-
- if (!top_ok || !uh_ok || !alloc_ok || !dealloc_ok) {
- retval = 0;
- init_counter = 0;
- if (top_ok)
- pthread_key_delete(top_key);
- if (uh_ok)
- pthread_key_delete(uh_key);
- if (alloc_ok)
- pthread_key_delete(alloc_key);
- if (dealloc_ok)
- pthread_key_delete(dealloc_key);
- }
+ int top_ok = (pthread_key_create(&top_key, 0) == 0);
+ int uh_ok = (pthread_key_create(&uh_key, 0) == 0);
+ int alloc_ok = (pthread_key_create(&alloc_key, 0) == 0);
+ int dealloc_ok = (pthread_key_create(&dealloc_key, 0) == 0);
+
+ if (!top_ok || !uh_ok || !alloc_ok || !dealloc_ok) {
+ retval = 0;
+ init_counter = 0;
+ if (top_ok)
+ pthread_key_delete(top_key);
+ if (uh_ok)
+ pthread_key_delete(uh_key);
+ if (alloc_ok)
+ pthread_key_delete(alloc_key);
+ if (dealloc_ok)
+ pthread_key_delete(dealloc_key);
+ }
}
pthread_mutex_unlock(&init_mtx);
@@ -121,16 +121,16 @@ void except_deinit(void)
assert (init_counter > 0);
if (--init_counter == 0) {
- pthread_key_delete(top_key);
- pthread_key_delete(uh_key);
- pthread_key_delete(alloc_key);
- pthread_key_delete(dealloc_key);
+ pthread_key_delete(top_key);
+ pthread_key_delete(uh_key);
+ pthread_key_delete(alloc_key);
+ pthread_key_delete(dealloc_key);
}
pthread_mutex_unlock(&init_mtx);
}
-#else /* no thread support */
+#else /* no thread support */
static int init_counter;
static void unhandled_catcher(except_t *);
@@ -175,9 +175,9 @@ void except_deinit(void)
static int match(const volatile except_id_t *thrown, const except_id_t *caught)
{
int group_match = (caught->except_group == XCEPT_GROUP_ANY ||
- caught->except_group == thrown->except_group);
+ caught->except_group == thrown->except_group);
int code_match = (caught->except_code == XCEPT_CODE_ANY ||
- caught->except_code == thrown->except_code);
+ caught->except_code == thrown->except_code);
return group_match && code_match;
}
@@ -187,31 +187,31 @@ G_GNUC_NORETURN WS_MSVC_NORETURN static void do_throw(except_t *except)
struct except_stacknode *top;
assert (except->except_id.except_group != 0 &&
- except->except_id.except_code != 0);
+ except->except_id.except_code != 0);
for (top = get_top(); top != 0; top = top->except_down) {
- if (top->except_type == XCEPT_CLEANUP) {
- top->except_info.except_cleanup->except_func(top->except_info.except_cleanup->except_context);
- } else {
- struct except_catch *catcher = top->except_info.except_catcher;
- const except_id_t *pi = catcher->except_id;
- size_t i;
-
- assert (top->except_type == XCEPT_CATCHER);
- except_free(catcher->except_obj.except_dyndata);
-
- for (i = 0; i < catcher->except_size; pi++, i++) {
- if (match(&except->except_id, pi)) {
- catcher->except_obj = *except;
- set_top(top);
- longjmp(catcher->except_jmp, 1);
- }
- }
- }
+ if (top->except_type == XCEPT_CLEANUP) {
+ top->except_info.except_cleanup->except_func(top->except_info.except_cleanup->except_context);
+ } else {
+ struct except_catch *catcher = top->except_info.except_catcher;
+ const except_id_t *pi = catcher->except_id;
+ size_t i;
+
+ assert (top->except_type == XCEPT_CATCHER);
+ except_free(catcher->except_obj.except_dyndata);
+
+ for (i = 0; i < catcher->except_size; pi++, i++) {
+ if (match(&except->except_id, pi)) {
+ catcher->except_obj = *except;
+ set_top(top);
+ longjmp(catcher->except_jmp, 1);
+ }
+ }
+ }
}
set_top(top);
- get_catcher()(except); /* unhandled exception */
+ get_catcher()(except); /* unhandled exception */
abort();
}
@@ -219,12 +219,12 @@ static void unhandled_catcher(except_t *except)
{
if (except->except_message == NULL) {
fprintf(stderr, "Unhandled exception (group=%ld, code=%ld)\n",
- except->except_id.except_group,
- except->except_id.except_code);
+ except->except_id.except_group,
+ except->except_id.except_code);
} else {
fprintf(stderr, "Unhandled exception (\"%s\", group=%ld, code=%ld)\n",
- except->except_message, except->except_id.except_group,
- except->except_id.except_code);
+ except->except_message, except->except_id.except_group,
+ except->except_id.except_code);
}
abort();
}
@@ -236,7 +236,7 @@ static void stack_push(struct except_stacknode *node)
}
void except_setup_clean(struct except_stacknode *esn,
- struct except_cleanup *ecl, void (*cleanf)(void *), void *context)
+ struct except_cleanup *ecl, void (*cleanf)(void *), void *context)
{
esn->except_type = XCEPT_CLEANUP;
ecl->except_func = cleanf;
@@ -246,7 +246,7 @@ void except_setup_clean(struct except_stacknode *esn,
}
void except_setup_try(struct except_stacknode *esn,
- struct except_catch *ech, const except_id_t id[], size_t size)
+ struct except_catch *ech, const except_id_t id[], size_t size)
{
ech->except_id = id;
ech->except_size = size;
@@ -369,7 +369,7 @@ void *except_alloc(size_t size)
void *ptr = get_alloc()(size);
if (ptr == 0)
- except_throw(XCEPT_BAD_ALLOC, 0, "out of memory");
+ except_throw(XCEPT_BAD_ALLOC, 0, "out of memory");
return ptr;
}
@@ -395,7 +395,7 @@ static void bottom_level(void)
fgets(buf, sizeof buf, stdin);
if (buf[0] >= 0 && toupper(buf[0]) == 'Y')
- except_throw(1, 1, "nasty exception");
+ except_throw(1, 1, "nasty exception");
}
static void top_level(void)
@@ -418,33 +418,33 @@ int main(int argc, char **argv)
/* outer */
except_try_push(catch, 2, &ex);
if (!ex) {
- /* inner */
- except_try_push(catch, 2, &ex);
- if (!ex) {
- top_level();
- } else {
- /* inner catch */
- msg = except_message(ex);
- if (msg == NULL) {
- printf("caught exception (inner): s=%ld, c=%ld\n",
- except_group(ex), except_code(ex));
- } else {
- printf("caught exception (inner): \"%s\", s=%ld, c=%ld\n",
- msg, except_group(ex), except_code(ex));
- }
- except_rethrow(ex);
- }
- except_try_pop();
+ /* inner */
+ except_try_push(catch, 2, &ex);
+ if (!ex) {
+ top_level();
+ } else {
+ /* inner catch */
+ msg = except_message(ex);
+ if (msg == NULL) {
+ printf("caught exception (inner): s=%ld, c=%ld\n",
+ except_group(ex), except_code(ex));
+ } else {
+ printf("caught exception (inner): \"%s\", s=%ld, c=%ld\n",
+ msg, except_group(ex), except_code(ex));
+ }
+ except_rethrow(ex);
+ }
+ except_try_pop();
} else {
- /* outer catch */
- msg = except_message(ex);
- if (msg == NULL) {
- printf("caught exception (outer): s=%ld, c=%ld\n",
- except_group(ex), except_code(ex));
- } else {
- printf("caught exception (outer): \"%s\", s=%ld, c=%ld\n",
- except_message(ex), except_group(ex), except_code(ex));
- }
+ /* outer catch */
+ msg = except_message(ex);
+ if (msg == NULL) {
+ printf("caught exception (outer): s=%ld, c=%ld\n",
+ except_group(ex), except_code(ex));
+ } else {
+ printf("caught exception (outer): \"%s\", s=%ld, c=%ld\n",
+ except_message(ex), except_group(ex), except_code(ex));
+ }
}
except_try_pop();
except_throw(99, 99, "exception in main");
@@ -453,3 +453,16 @@ int main(int argc, char **argv)
#endif
+
+/*
+ * Editor modelines - http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */