summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2001-09-10 20:30:09 -0400
committerTheodore Ts'o <tytso@mit.edu>2001-09-10 20:30:09 -0400
commitce2722f86de298ad1a8965f55a453b5723d2b2b9 (patch)
treed6b5a6885c61a237383c1b39fb2698274d0e09db /lib
parent761da73ad17a154cde85c8bc8b9125276272687e (diff)
downloade2fsprogs-ce2722f86de298ad1a8965f55a453b5723d2b2b9.tar.gz
compare.c (uuid_compare), copy.c (uuid_copy),
isnull.c (uuid_is_null), pack.c (uuid_pack), parse.c (uuid_parse), unpack.c (uuid_unpack), unparse.c (uuid_unparse), uuid.h, uuidP.h, uuid_time.c (uuid_time, uuid_type, uuid_variant): Use const for pointer variables that we don't modify. Add the appropriate ifdef's in uuid.h to make it be C++ friendly.
Diffstat (limited to 'lib')
-rw-r--r--lib/uuid/ChangeLog10
-rw-r--r--lib/uuid/compare.c2
-rw-r--r--lib/uuid/copy.c7
-rw-r--r--lib/uuid/isnull.c6
-rw-r--r--lib/uuid/pack.c2
-rw-r--r--lib/uuid/parse.c9
-rw-r--r--lib/uuid/unpack.c6
-rw-r--r--lib/uuid/unparse.c2
-rw-r--r--lib/uuid/uuid.h24
-rw-r--r--lib/uuid/uuidP.h4
-rw-r--r--lib/uuid/uuid_time.c6
11 files changed, 49 insertions, 29 deletions
diff --git a/lib/uuid/ChangeLog b/lib/uuid/ChangeLog
index a63d278e..0501731a 100644
--- a/lib/uuid/ChangeLog
+++ b/lib/uuid/ChangeLog
@@ -1,3 +1,13 @@
+2001-09-10 Theodore Tso <tytso@valinux.com>
+
+ * compare.c (uuid_compare), copy.c (uuid_copy),
+ isnull.c (uuid_is_null), pack.c (uuid_pack),
+ parse.c (uuid_parse), unpack.c (uuid_unpack),
+ unparse.c (uuid_unparse), uuid.h, uuidP.h,
+ uuid_time.c (uuid_time, uuid_type, uuid_variant):
+ Use const for pointer variables that we don't modify. Add
+ the appropriate ifdef's in uuid.h to make it be C++ friendly.
+
2001-09-02 Theodore Tso <tytso@thunk.org>
* Release of E2fsprogs 1.24a
diff --git a/lib/uuid/compare.c b/lib/uuid/compare.c
index cc335f5e..0f9737c5 100644
--- a/lib/uuid/compare.c
+++ b/lib/uuid/compare.c
@@ -16,7 +16,7 @@
#define UUCMP(u1,u2) if (u1 != u2) return((u1 < u2) ? -1 : 1);
-int uuid_compare(uuid_t uu1, uuid_t uu2)
+int uuid_compare(const uuid_t uu1, const uuid_t uu2)
{
struct uuid uuid1, uuid2;
diff --git a/lib/uuid/copy.c b/lib/uuid/copy.c
index 213a9e51..b9a34dac 100644
--- a/lib/uuid/copy.c
+++ b/lib/uuid/copy.c
@@ -11,10 +11,11 @@
#include "uuidP.h"
-void uuid_copy(uuid_t dst, uuid_t src)
+void uuid_copy(uuid_t dst, const uuid_t src)
{
- unsigned char *cp1, *cp2;
- int i;
+ unsigned char *cp1;
+ const unsigned char *cp2;
+ int i;
for (i=0, cp1 = dst, cp2 = src; i < 16; i++)
*cp1++ = *cp2++;
diff --git a/lib/uuid/isnull.c b/lib/uuid/isnull.c
index ea3e5540..8aba238a 100644
--- a/lib/uuid/isnull.c
+++ b/lib/uuid/isnull.c
@@ -12,10 +12,10 @@
#include "uuidP.h"
/* Returns 1 if the uuid is the NULL uuid */
-int uuid_is_null(uuid_t uu)
+int uuid_is_null(const uuid_t uu)
{
- unsigned char *cp;
- int i;
+ const unsigned char *cp;
+ int i;
for (i=0, cp = uu; i < 16; i++)
if (*cp++)
diff --git a/lib/uuid/pack.c b/lib/uuid/pack.c
index b7a1a91a..1303ef52 100644
--- a/lib/uuid/pack.c
+++ b/lib/uuid/pack.c
@@ -12,7 +12,7 @@
#include <string.h>
#include "uuidP.h"
-void uuid_pack(struct uuid *uu, uuid_t ptr)
+void uuid_pack(const struct uuid *uu, uuid_t ptr)
{
__u32 tmp;
unsigned char *out = ptr;
diff --git a/lib/uuid/parse.c b/lib/uuid/parse.c
index 6c6fe315..13d52973 100644
--- a/lib/uuid/parse.c
+++ b/lib/uuid/parse.c
@@ -16,11 +16,12 @@
#include "uuidP.h"
-int uuid_parse(char *in, uuid_t uu)
+int uuid_parse(const char *in, uuid_t uu)
{
- struct uuid uuid;
- int i;
- char *cp, buf[3];
+ struct uuid uuid;
+ int i;
+ const char *cp;
+ char buf[3];
if (strlen(in) != 36)
return -1;
diff --git a/lib/uuid/unpack.c b/lib/uuid/unpack.c
index 46ab6bc5..02005dde 100644
--- a/lib/uuid/unpack.c
+++ b/lib/uuid/unpack.c
@@ -12,10 +12,10 @@
#include <string.h>
#include "uuidP.h"
-void uuid_unpack(uuid_t in, struct uuid *uu)
+void uuid_unpack(const uuid_t in, struct uuid *uu)
{
- __u8 *ptr = in;
- __u32 tmp;
+ const __u8 *ptr = in;
+ __u32 tmp;
tmp = *ptr++;
tmp = (tmp << 8) | *ptr++;
diff --git a/lib/uuid/unparse.c b/lib/uuid/unparse.c
index bae5c1be..db3ef048 100644
--- a/lib/uuid/unparse.c
+++ b/lib/uuid/unparse.c
@@ -13,7 +13,7 @@
#include "uuidP.h"
-void uuid_unparse(uuid_t uu, char *out)
+void uuid_unparse(const uuid_t uu, char *out)
{
struct uuid uuid;
diff --git a/lib/uuid/uuid.h b/lib/uuid/uuid.h
index db0147c7..5720d7f0 100644
--- a/lib/uuid/uuid.h
+++ b/lib/uuid/uuid.h
@@ -24,14 +24,18 @@ typedef unsigned char uuid_t[16];
#define UUID_VARIANT_MICROSOFT 2
#define UUID_VARIANT_OTHER 3
+#ifdef __cplusplus
+extern "C" {
+#endif
+
/* clear.c */
void uuid_clear(uuid_t uu);
/* compare.c */
-int uuid_compare(uuid_t uu1, uuid_t uu2);
+int uuid_compare(const uuid_t uu1, const uuid_t uu2);
/* copy.c */
-void uuid_copy(uuid_t dst, uuid_t src);
+void uuid_copy(uuid_t dst, const uuid_t src);
/* gen_uuid.c */
void uuid_generate(uuid_t out);
@@ -39,17 +43,21 @@ void uuid_generate_random(uuid_t out);
void uuid_generate_time(uuid_t out);
/* isnull.c */
-int uuid_is_null(uuid_t uu);
+int uuid_is_null(const uuid_t uu);
/* parse.c */
-int uuid_parse(char *in, uuid_t uu);
+int uuid_parse(const char *in, uuid_t uu);
/* unparse.c */
-void uuid_unparse(uuid_t uu, char *out);
+void uuid_unparse(const uuid_t uu, char *out);
/* uuid_time.c */
-time_t uuid_time(uuid_t uu, struct timeval *ret_tv);
-int uuid_type(uuid_t uu);
-int uuid_variant(uuid_t uu);
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
+int uuid_type(const uuid_t uu);
+int uuid_variant(const uuid_t uu);
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _UUID_UUID_H */
diff --git a/lib/uuid/uuidP.h b/lib/uuid/uuidP.h
index e6bc00e1..50407c02 100644
--- a/lib/uuid/uuidP.h
+++ b/lib/uuid/uuidP.h
@@ -32,8 +32,8 @@ struct uuid {
/*
* prototypes
*/
-void uuid_pack(struct uuid *uu, uuid_t ptr);
-void uuid_unpack(uuid_t in, struct uuid *uu);
+void uuid_pack(const struct uuid *uu, uuid_t ptr);
+void uuid_unpack(const uuid_t in, struct uuid *uu);
diff --git a/lib/uuid/uuid_time.c b/lib/uuid/uuid_time.c
index 2783875d..dee87e10 100644
--- a/lib/uuid/uuid_time.c
+++ b/lib/uuid/uuid_time.c
@@ -20,7 +20,7 @@
#include "uuidP.h"
-time_t uuid_time(uuid_t uu, struct timeval *ret_tv)
+time_t uuid_time(const uuid_t uu, struct timeval *ret_tv)
{
struct uuid uuid;
__u32 high;
@@ -42,7 +42,7 @@ time_t uuid_time(uuid_t uu, struct timeval *ret_tv)
return tv.tv_sec;
}
-int uuid_type(uuid_t uu)
+int uuid_type(const uuid_t uu)
{
struct uuid uuid;
@@ -50,7 +50,7 @@ int uuid_type(uuid_t uu)
return ((uuid.time_hi_and_version >> 12) & 0xF);
}
-int uuid_variant(uuid_t uu)
+int uuid_variant(const uuid_t uu)
{
struct uuid uuid;
int var;