From: Siddhi Tadpatrikar Date: Mon, 14 Mar 2011 17:05:22 +0000 (-0400) Subject: Resolved the merge conflicts in src/tracecut.c X-Git-Tag: release-v1.1~9^2~11 X-Git-Url: https://git.fsl.cs.stonybrook.edu/?a=commitdiff_plain;h=45e22e984b9fa4e337ce35c1dc60670d0e2211b3;p=interaspect.git Resolved the merge conflicts in src/tracecut.c Merge branch 'tracecut' of /home/jseyster/git/aop/interaspect into tracecut Conflicts: src/tracecut.c --- 45e22e984b9fa4e337ce35c1dc60670d0e2211b3 diff --cc src/tracecut.c index f6e15bf,61a5ff8..4015e30 --- a/src/tracecut.c +++ b/src/tracecut.c @@@ -151,17 -155,50 +155,63 @@@ lookup_param (struct tc_tracecut *tc, c return NULL; } + /* Here's a cool trick I learned from the DTrace source code. This + function sets the error code in a tracecut object and also returns + that error code, so you can conveniently nestle it in the return + statement itself. */ + static enum tc_error + return_error (struct tc_tracecut *tc, enum tc_error tc_error) + { + /* The tc_error field holds the _first_ non success error code. */ + if (tc->tc_error == TC_SUCCESS) + tc->tc_error = tc_error; + + return tc_error; + } + + /** + * The first operation on a tracecut that fails stores its error code + * in the tracecut. This function returns that error code, or + * #TC_SUCCESS if all operations succeeded. Checking error codes this + * ways makes it possible to call several tracecut functions in + * sequence without individually checking their error codes. + * + * Use tc_reset_error() to set a tracecut's error code back to + * #TC_SUCCESS. + * + * \param tc The tracecut to check. + * \return The error code of the first failed operation on this + * tracecut, or TC_SUCCESS if no operations failed. + */ + enum tc_error + tc_error_code (struct tc_tracecut *tc) + { + return tc->tc_error; + } + + /** + * Clear the history of any failed operations on this tracecut. After + * calling this, tc_error_code() will return #TC_SUCCESS until some + * later tracecut operation fails. + * \param tc The tracecut to reset. + */ + void + tc_reset_error (struct tc_tracecut *tc) + { - tc->tc_error = TC_SUCCESS; ++ tc->tc_error = TC_SUCCESS; ++} ++ +enum tc_error +tc_check_param_type(const struct aop_type *type) +{ + if(aop_is_pointer_type (type) || + aop_is_all_signed_subtype (type) || + aop_is_all_unsigned_subtype (type) || + aop_is_all_fp_subtype (type)) { + return TC_SUCCESS; + } + + return TC_INVAL; } /** @@@ -191,17 -228,15 +241,17 @@@ tc_add_param (struct tc_tracecut *tc, c const struct aop_type *type) { struct tc_param *param = NULL; + enum tc_error tc_err = TC_SUCCESS; if (tc_in_compilation) - return TC_BAD_CONTEXT; + return return_error (tc, TC_BAD_CONTEXT); - if (!aop_is_pointer_type (type)) - return return_error (tc, TC_INVAL); + tc_err = tc_check_param_type(type); + if(tc_err != TC_SUCCESS) + return tc_err; if (lookup_param (tc, name) != NULL) - return TC_DUPLICATE;; + return return_error (tc, TC_DUPLICATE); param = (struct tc_param *)malloc (sizeof (struct tc_param)); if (param == NULL)