summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorRajesh Amaravathi <rajesh@redhat.com>2012-02-28 12:57:26 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-29 02:14:48 -0800
commitca8e61069b4fec42efa76da2070d362607770bc7 (patch)
tree437490bfda9171ad065185ad35b46892d3792f5d /libglusterfs
parent2da18b6724b7daf7c3a973515fc3d59e7d2c4622 (diff)
nfs/doc: corrections
corrections in nfs configuration helpers displayed with "gluster volume set help". Change-Id: Iffc0d10eacbaea647270cd875d4cbd5f80333671 BUG: 771876 Signed-off-by: Rajesh Amaravathi <rajesh@redhat.com> Reviewed-on: http://review.gluster.com/2829 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'libglusterfs')
0 files changed, 0 insertions, 0 deletions
>30
-rw-r--r--libglusterfs/src/dict.h1
2 files changed, 31 insertions, 0 deletions
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
index 40f575d52d0..2ad1ae1abff 100644
--- a/libglusterfs/src/dict.c
+++ b/libglusterfs/src/dict.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <inttypes.h>
+#include <limits.h>
#ifndef _CONFIG_H
#define _CONFIG_H
@@ -1166,6 +1167,35 @@ data_to_uint16 (data_t *data)
return strtol (str, NULL, 0);
}
+uint8_t
+data_to_uint8 (data_t *data)
+{
+ uint32_t value = 0;
+
+ if (!data) {
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data is NULL");
+ return -1;
+ }
+
+ char *str = alloca (data->len + 1);
+ if (!str)
+ return -1;
+
+ memcpy (str, data->data, data->len);
+ str[data->len] = '\0';
+
+ errno = 0;
+ value = strtol (str, NULL, 0);
+
+ if ((UCHAR_MAX - value) < 0) {
+ errno = ERANGE;
+ gf_log_callingfn ("dict", GF_LOG_WARNING, "data conversion overflow detected (%s)", strerror(errno));
+ return -1;
+ }
+
+ return (uint8_t) value;
+}
+
char *
data_to_str (data_t *data)
{
diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h
index 121f84be5a6..c68c3af873b 100644
--- a/libglusterfs/src/dict.h
+++ b/libglusterfs/src/dict.h
@@ -110,6 +110,7 @@ int8_t data_to_int8 (data_t *data);
uint64_t data_to_uint64 (data_t *data);
uint32_t data_to_uint32 (data_t *data);
uint16_t data_to_uint16 (data_t *data);
+uint8_t data_to_uint8 (data_t *data);
data_t *data_from_ptr (void *value);
data_t *data_from_static_ptr (void *value);