|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] Revert "make xen ocaml safe-strings compliant"
commit 3a6719f40f8160a9a5924d16de51024003c2caa9
Author: Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Thu Feb 8 18:05:44 2018 +0000
Commit: Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Mon Feb 12 11:05:35 2018 +0000
Revert "make xen ocaml safe-strings compliant"
This reverts commit df1e4c6e7f8892e950433ff33c215df0cd7b30f7.
Oxenstored is broken by this change.
---
tools/ocaml/libs/xb/xb.ml | 6 +++---
tools/ocaml/xenstored/logging.ml | 22 +++++++++++-----------
tools/ocaml/xenstored/stdext.ml | 2 +-
tools/ocaml/xenstored/utils.ml | 18 +++++++++---------
4 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/tools/ocaml/libs/xb/xb.ml b/tools/ocaml/libs/xb/xb.ml
index aa2cf98..50944b5 100644
--- a/tools/ocaml/libs/xb/xb.ml
+++ b/tools/ocaml/libs/xb/xb.ml
@@ -84,7 +84,7 @@ let read_mmap back con s len =
let read con s len =
match con.backend with
- | Fd backfd -> read_fd backfd con (Bytes.of_string s) len
+ | Fd backfd -> read_fd backfd con s len
| Xenmmap backmmap -> read_mmap backmmap con s len
let write_fd back con s len =
@@ -98,7 +98,7 @@ let write_mmap back con s len =
let write con s len =
match con.backend with
- | Fd backfd -> write_fd backfd con (Bytes.of_string s) len
+ | Fd backfd -> write_fd backfd con s len
| Xenmmap backmmap -> write_mmap backmmap con s len
(* NB: can throw Reconnect *)
@@ -147,7 +147,7 @@ let input con =
| NoHdr (i, buf) ->
(* we complete the partial header *)
if sz > 0 then
- String.blit s 0 (Bytes.of_string buf)
(Partial.header_size () - i) sz;
+ String.blit s 0 buf (Partial.header_size () - i) sz;
con.partial_in <- if sz = i then
HaveHdr (Partial.of_string buf) else NoHdr (i - sz, buf)
);
diff --git a/tools/ocaml/xenstored/logging.ml b/tools/ocaml/xenstored/logging.ml
index e3c769f..0c0d03d 100644
--- a/tools/ocaml/xenstored/logging.ml
+++ b/tools/ocaml/xenstored/logging.ml
@@ -60,11 +60,11 @@ type logger =
let truncate_line nb_chars line =
if String.length line > nb_chars - 1 then
let len = max (nb_chars - 1) 2 in
- let dst_line = Bytes.create len in
- Bytes.blit_string line 0 dst_line 0 (len - 2);
- Bytes.set dst_line (len-2) '.';
- Bytes.set dst_line (len-1) '.';
- Bytes.to_string dst_line
+ let dst_line = String.create len in
+ String.blit line 0 dst_line 0 (len - 2);
+ dst_line.[len-2] <- '.';
+ dst_line.[len-1] <- '.';
+ dst_line
else line
let log_rotate ref_ch log_file log_nb_files =
@@ -252,13 +252,13 @@ let string_of_access_type = function
*)
let sanitize_data data =
- let data = Bytes.copy data in
- for i = 0 to Bytes.length data - 1
+ let data = String.copy data in
+ for i = 0 to String.length data - 1
do
- if Bytes.get data i = '\000' then
- Bytes.set data i ' '
+ if data.[i] = '\000' then
+ data.[i] <- ' '
done;
- String.escaped (Bytes.to_string data)
+ String.escaped data
let activate_access_log = ref true
let access_log_destination = ref (File (Paths.xen_log_dir ^
"/xenstored-access.log"))
@@ -291,7 +291,7 @@ let access_logging ~con ~tid ?(data="") ~level access_type =
let date = string_of_date() in
let tid = string_of_tid ~con tid in
let access_type = string_of_access_type
access_type in
- let data = sanitize_data (Bytes.of_string data)
in
+ let data = sanitize_data data in
let prefix = prefix !access_log_destination
date in
let msg = Printf.sprintf "%s %s %s %s" prefix
tid access_type data in
logger.write ~level msg)
diff --git a/tools/ocaml/xenstored/stdext.ml b/tools/ocaml/xenstored/stdext.ml
index 41411ee..b8a8fd0 100644
--- a/tools/ocaml/xenstored/stdext.ml
+++ b/tools/ocaml/xenstored/stdext.ml
@@ -122,7 +122,7 @@ let pidfile_write filename =
let pid = Unix.getpid () in
let buf = string_of_int pid ^ "\n" in
let len = String.length buf in
- if Unix.write fd (Bytes.of_string buf) 0 len <> len
+ if Unix.write fd buf 0 len <> len
then failwith "pidfile_write failed";
)
(fun () -> Unix.close fd)
diff --git a/tools/ocaml/xenstored/utils.ml b/tools/ocaml/xenstored/utils.ml
index c96def7..e89c1af 100644
--- a/tools/ocaml/xenstored/utils.ml
+++ b/tools/ocaml/xenstored/utils.ml
@@ -45,23 +45,23 @@ let get_hierarchy path =
let hexify s =
let hexseq_of_char c = sprintf "%02x" (Char.code c) in
- let hs = Bytes.create (String.length s * 2) in
+ let hs = String.create (String.length s * 2) in
for i = 0 to String.length s - 1
do
let seq = hexseq_of_char s.[i] in
- Bytes.set hs (i * 2) seq.[0];
- Bytes.set hs (i * 2 + 1) seq.[1];
+ hs.[i * 2] <- seq.[0];
+ hs.[i * 2 + 1] <- seq.[1];
done;
- Bytes.to_string hs
+ hs
let unhexify hs =
let char_of_hexseq seq0 seq1 = Char.chr (int_of_string (sprintf
"0x%c%c" seq0 seq1)) in
- let s = Bytes.create (String.length hs / 2) in
- for i = 0 to Bytes.length s - 1
+ let s = String.create (String.length hs / 2) in
+ for i = 0 to String.length s - 1
do
- Bytes.set s i (char_of_hexseq hs.[i * 2] hs.[i * 2 + 1])
+ s.[i] <- char_of_hexseq hs.[i * 2] hs.[i * 2 + 1]
done;
- Bytes.to_string s
+ s
let trim_path path =
try
@@ -85,7 +85,7 @@ let create_unix_socket name =
let read_file_single_integer filename =
let fd = Unix.openfile filename [ Unix.O_RDONLY ] 0o640 in
let buf = String.make 20 (char_of_int 0) in
- let sz = Unix.read fd (Bytes.of_string buf) 0 20 in
+ let sz = Unix.read fd buf 0 20 in
Unix.close fd;
int_of_string (String.sub buf 0 sz)
--
generated by git-patchbot for /home/xen/git/xen.git#master
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |