lttng-dev.lists.lttng.org archive mirror
 help / color / mirror / Atom feed
* [PATCH lttng-ust v2] Add libc errno translation layer to UST error code
@ 2012-11-09 18:16 David Goulet
  0 siblings, 0 replies; 2+ messages in thread
From: David Goulet @ 2012-11-09 18:16 UTC (permalink / raw)
  To: lttng-dev

Also add four new possible code being EEXIST, EINVAL, ENOSYS and EPERM.

Signed-off-by: David Goulet <dgoulet@efficios.com>
---
 include/lttng/ust-error.h          |    6 +++++-
 liblttng-ust-comm/lttng-ust-comm.c |    4 ++++
 liblttng-ust/lttng-ust-comm.c      |   26 +++++++++++++++++++++++---
 3 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/include/lttng/ust-error.h b/include/lttng/ust-error.h
index 49890a9..0d829f8 100644
--- a/include/lttng/ust-error.h
+++ b/include/lttng/ust-error.h
@@ -36,7 +36,11 @@
 enum lttng_ust_error_code {
 	LTTNG_UST_OK = 0,			/* Ok */
 	LTTNG_UST_ERR = 1024,			/* Unknown Error */
-	LTTNG_UST_ERR_NOENT,			/* No entry */
+	LTTNG_UST_ERR_NOENT = 1025,		/* No entry */
+	LTTNG_UST_ERR_EXIST = 1026,     /* Object exists */
+	LTTNG_UST_ERR_INVAL = 1027,     /* Invalid argument */
+	LTTNG_UST_ERR_PERM  = 1028,     /* Permission denied */
+	LTTNG_UST_ERR_NOSYS = 1029,     /* Not implemented */
 
 	/* MUST be last element */
 	LTTNG_UST_ERR_NR,			/* Last element */
diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c
index 8765ea6..9a67ea1 100644
--- a/liblttng-ust-comm/lttng-ust-comm.c
+++ b/liblttng-ust-comm/lttng-ust-comm.c
@@ -44,6 +44,10 @@ static const char *ustcomm_readable_code[] = {
 	[ USTCOMM_CODE_OFFSET(LTTNG_UST_OK) ] = "Success",
 	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR) ] = "Unknown error",
 	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOENT) ] = "No entry",
+	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_EXIST) ] = "Object already exists",
+	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL) ] = "Invalid argument",
+	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PERM) ] = "Permission denied",
+	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOSYS) ] = "Not implemented",
 };
 
 /*
diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
index f11b7d0..6eec73c 100644
--- a/liblttng-ust/lttng-ust-comm.c
+++ b/liblttng-ust/lttng-ust-comm.c
@@ -376,9 +376,29 @@ end:
 		 * we already have a more precise error message to
 		 * report.
 		 */
-		if (ret > -LTTNG_UST_ERR)
-			lur.ret_code = -LTTNG_UST_ERR;
-		else
+		if (ret > -LTTNG_UST_ERR) {
+			/* Translate code to UST error. */
+			switch (ret) {
+			case -EEXIST:
+				lur.ret_code = -LTTNG_UST_ERR_EXIST;
+				break;
+			case -EINVAL:
+				lur.ret_code = -LTTNG_UST_ERR_INVAL;
+				break;
+			case -ENOENT:
+				lur.ret_code = -LTTNG_UST_ERR_NOENT;
+				break;
+			case -EPERM:
+				lur.ret_code = -LTTNG_UST_ERR_PERM;
+				break;
+			case -ENOSYS:
+				lur.ret_code = -LTTNG_UST_ERR_NOSYS;
+				break;
+			default:
+				lur.ret_code = -LTTNG_UST_ERR;
+				break;
+			}
+		} else
 			lur.ret_code = ret;
 	}
 	if (ret >= 0) {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH lttng-ust v2] Add libc errno translation layer to UST error code
       [not found] <1352484978-19518-1-git-send-email-dgoulet@efficios.com>
@ 2012-11-09 18:21 ` Mathieu Desnoyers
  0 siblings, 0 replies; 2+ messages in thread
From: Mathieu Desnoyers @ 2012-11-09 18:21 UTC (permalink / raw)
  To: David Goulet; +Cc: lttng-dev

* David Goulet (dgoulet@efficios.com) wrote:
> Also add four new possible code being EEXIST, EINVAL, ENOSYS and EPERM.

merged with minor style changes,

Thanks,

Mathieu

> 
> Signed-off-by: David Goulet <dgoulet@efficios.com>
> ---
>  include/lttng/ust-error.h          |    6 +++++-
>  liblttng-ust-comm/lttng-ust-comm.c |    4 ++++
>  liblttng-ust/lttng-ust-comm.c      |   26 +++++++++++++++++++++++---
>  3 files changed, 32 insertions(+), 4 deletions(-)
> 
> diff --git a/include/lttng/ust-error.h b/include/lttng/ust-error.h
> index 49890a9..0d829f8 100644
> --- a/include/lttng/ust-error.h
> +++ b/include/lttng/ust-error.h
> @@ -36,7 +36,11 @@
>  enum lttng_ust_error_code {
>  	LTTNG_UST_OK = 0,			/* Ok */
>  	LTTNG_UST_ERR = 1024,			/* Unknown Error */
> -	LTTNG_UST_ERR_NOENT,			/* No entry */
> +	LTTNG_UST_ERR_NOENT = 1025,		/* No entry */
> +	LTTNG_UST_ERR_EXIST = 1026,     /* Object exists */
> +	LTTNG_UST_ERR_INVAL = 1027,     /* Invalid argument */
> +	LTTNG_UST_ERR_PERM  = 1028,     /* Permission denied */
> +	LTTNG_UST_ERR_NOSYS = 1029,     /* Not implemented */
>  
>  	/* MUST be last element */
>  	LTTNG_UST_ERR_NR,			/* Last element */
> diff --git a/liblttng-ust-comm/lttng-ust-comm.c b/liblttng-ust-comm/lttng-ust-comm.c
> index 8765ea6..9a67ea1 100644
> --- a/liblttng-ust-comm/lttng-ust-comm.c
> +++ b/liblttng-ust-comm/lttng-ust-comm.c
> @@ -44,6 +44,10 @@ static const char *ustcomm_readable_code[] = {
>  	[ USTCOMM_CODE_OFFSET(LTTNG_UST_OK) ] = "Success",
>  	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR) ] = "Unknown error",
>  	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOENT) ] = "No entry",
> +	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_EXIST) ] = "Object already exists",
> +	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL) ] = "Invalid argument",
> +	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PERM) ] = "Permission denied",
> +	[ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOSYS) ] = "Not implemented",
>  };
>  
>  /*
> diff --git a/liblttng-ust/lttng-ust-comm.c b/liblttng-ust/lttng-ust-comm.c
> index f11b7d0..6eec73c 100644
> --- a/liblttng-ust/lttng-ust-comm.c
> +++ b/liblttng-ust/lttng-ust-comm.c
> @@ -376,9 +376,29 @@ end:
>  		 * we already have a more precise error message to
>  		 * report.
>  		 */
> -		if (ret > -LTTNG_UST_ERR)
> -			lur.ret_code = -LTTNG_UST_ERR;
> -		else
> +		if (ret > -LTTNG_UST_ERR) {
> +			/* Translate code to UST error. */
> +			switch (ret) {
> +			case -EEXIST:
> +				lur.ret_code = -LTTNG_UST_ERR_EXIST;
> +				break;
> +			case -EINVAL:
> +				lur.ret_code = -LTTNG_UST_ERR_INVAL;
> +				break;
> +			case -ENOENT:
> +				lur.ret_code = -LTTNG_UST_ERR_NOENT;
> +				break;
> +			case -EPERM:
> +				lur.ret_code = -LTTNG_UST_ERR_PERM;
> +				break;
> +			case -ENOSYS:
> +				lur.ret_code = -LTTNG_UST_ERR_NOSYS;
> +				break;
> +			default:
> +				lur.ret_code = -LTTNG_UST_ERR;
> +				break;
> +			}
> +		} else
>  			lur.ret_code = ret;
>  	}
>  	if (ret >= 0) {
> -- 
> 1.7.10.4
> 
> 
> _______________________________________________
> lttng-dev mailing list
> lttng-dev@lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-09 18:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1352484978-19518-1-git-send-email-dgoulet@efficios.com>
2012-11-09 18:21 ` [PATCH lttng-ust v2] Add libc errno translation layer to UST error code Mathieu Desnoyers
2012-11-09 18:16 David Goulet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).