From owner-p4-projects@FreeBSD.ORG Tue Jun 18 13:46:34 2013 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9D80EDD3; Tue, 18 Jun 2013 13:46:34 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 5E880DD1 for ; Tue, 18 Jun 2013 13:46:34 +0000 (UTC) (envelope-from jonathan@freebsd.org) Received: from skunkworks.freebsd.org (skunkworks6.freebsd.org [IPv6:2001:1900:2254:2068::682:0]) by mx1.freebsd.org (Postfix) with ESMTP id 4F05B1AAF for ; Tue, 18 Jun 2013 13:46:34 +0000 (UTC) Received: from skunkworks.freebsd.org ([127.0.1.74]) by skunkworks.freebsd.org (8.14.7/8.14.7) with ESMTP id r5IDkY0j013661 for ; Tue, 18 Jun 2013 13:46:34 GMT (envelope-from jonathan@freebsd.org) Received: (from perforce@localhost) by skunkworks.freebsd.org (8.14.7/8.14.6/Submit) id r5IDkY8Z013658 for perforce@freebsd.org; Tue, 18 Jun 2013 13:46:34 GMT (envelope-from jonathan@freebsd.org) Date: Tue, 18 Jun 2013 13:46:34 GMT Message-Id: <201306181346.r5IDkY8Z013658@skunkworks.freebsd.org> X-Authentication-Warning: skunkworks.freebsd.org: perforce set sender to jonathan@freebsd.org using -f From: Jonathan Anderson Subject: PERFORCE change 229888 for review To: Perforce Change Reviews Precedence: bulk X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.14 List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jun 2013 13:46:34 -0000 http://p4web.freebsd.org/@@229888?ac=10 Change 229888 by jonathan@jonathan-on-zenith on 2013/06/18 13:45:52 Report errors with ev_err() rather than a return code. Instrumentation should be very simplle: it's better to call a void tesla_update_state() than try to handle errors from generated instrumentation. Instead, we use the new ev_errr() event handler from within tesla_update_state() to handle errors like ENOMEM. This change will require (not-yet-committed) TESLA instrumenter changes. Affected files ... .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#8 edit .. //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#6 edit Differences ... ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/include/libtesla.h#8 (text+ko) ==== @@ -194,7 +194,7 @@ /** * Update all automata instances that match a given key to a new state. */ -int32_t tesla_update_state(enum tesla_context context, uint32_t class_id, +void tesla_update_state(enum tesla_context context, uint32_t class_id, const struct tesla_key *key, const char *name, const char *description, const struct tesla_transitions*); ==== //depot/projects/ctsrd/tesla/src/sys/contrib/tesla/libtesla/tesla_update.c#6 (text+ko) ==== @@ -37,23 +37,16 @@ #include #endif -#define CHECK(fn, ...) do { \ - int err = fn(__VA_ARGS__); \ - if (err != TESLA_SUCCESS) { \ - PRINT("error in " #fn ": %s\n", tesla_strerror(err)); \ - return (err); \ - } \ -} while(0) - #define DEBUG_NAME "libtesla.state.update" #define PRINT(...) DEBUG(libtesla.state.update, __VA_ARGS__) -int32_t +void tesla_update_state(enum tesla_context tesla_context, uint32_t class_id, const struct tesla_key *pattern, const char *name, const char *description, const struct tesla_transitions *trans) { + int err; if (tesla_debugging(DEBUG_NAME)) { /* We should never see with multiple <> transitions. */ @@ -80,17 +73,20 @@ PRINT("\n----\n"); struct tesla_store *store; - CHECK(tesla_store_get, tesla_context, TESLA_MAX_CLASSES, - TESLA_MAX_INSTANCES, &store); + err = tesla_store_get(tesla_context, TESLA_MAX_CLASSES, + TESLA_MAX_INSTANCES, &store); + if (err != TESLA_SUCCESS) + return; + PRINT("store: 0x%tx\n", (intptr_t) store); struct tesla_class *class; - CHECK(tesla_class_get, store, class_id, &class, name, description); + err = tesla_class_get(store, class_id, &class, name, description); + if (err != TESLA_SUCCESS) + return; print_class(class); - int error = TESLA_SUCCESS; - // Did we match any instances? bool matched_something = false; @@ -134,7 +130,8 @@ case FORK: { if (cloned >= max_clones) { - error = TESLA_ERROR_ENOMEM; + err = TESLA_ERROR_ENOMEM; + ev_err(class, err, "too many clones"); goto cleanup; } @@ -154,11 +151,19 @@ for (size_t i = 0; i < cloned; i++) { struct clone_info *c = clones + i; struct tesla_instance *clone; - CHECK(tesla_instance_clone, class, c->old, &clone); + err = tesla_instance_clone(class, c->old, &clone); + if (err != TESLA_SUCCESS) { + ev_err(class, err, "failed to clone instance"); + goto cleanup; + } tesla_key new_name = *pattern; new_name.tk_mask &= c->transition->to_mask; - CHECK(tesla_key_union, &clone->ti_key, &new_name); + err = tesla_key_union(&clone->ti_key, &new_name); + if (err != TESLA_SUCCESS) { + ev_err(class, err, "failed to union keys"); + goto cleanup; + } clone->ti_state = c->transition->to; @@ -174,7 +179,12 @@ const tesla_transition *t = trans->transitions + i; if (t->flags & TESLA_TRANS_INIT) { struct tesla_instance *inst; - CHECK(tesla_instance_new, class, pattern, t->to, &inst); + err = tesla_instance_new(class, pattern, t->to, &inst); + if (err != TESLA_SUCCESS) { + ev_err(class, err, "failed to create instance"); + goto cleanup; + } + assert(tesla_instance_active(inst)); matched_something = true; @@ -201,7 +211,6 @@ cleanup: tesla_class_put(class); - return error; } enum tesla_action_t