Skip to content

Commit 82091be

Browse files
committed
Merge pull request #38 from drbawb/feature/fix-bare-ptr
Update for rust-master: specify mutability of bare pointers, and width of integer literals.
2 parents a0c0ff7 + 3b1a653 commit 82091be

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/examples/zguide/helloworld-client/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fn main() {
1414

1515
let mut msg = zmq::Message::new();
1616

17-
for x in range(0, 10) {
17+
for x in range(0i, 10i) {
1818
println!("Sending Hello {}", x);
1919
requester.send(b"Hello", 0).unwrap();
2020

src/examples/zguide/weather-client/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ fn main() {
2525

2626
let mut total_temp = 0;
2727

28-
for _ in range(0, 100) {
28+
for _ in range(0i, 100i) {
2929
let string = subscriber.recv_str(0).unwrap();
3030
let chks: Vec<int> = string.as_slice().split(' ').map(|x| atoi(x)).collect();
3131
let (_zipcode, temperature, _relhumidity) = (chks.get(0), chks.get(1), chks.get(2));

src/examples/zguide/weather-server/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ fn main() {
1818
let mut rng = std::rand::weak_rng();
1919

2020
loop {
21-
let zipcode = rng.gen_range(0, 100000);
22-
let temperature = rng.gen_range(-80, 135);
23-
let relhumidity = rng.gen_range(10, 60);
21+
let zipcode = rng.gen_range(0i, 100000i);
22+
let temperature = rng.gen_range(-80i, 135i);
23+
let relhumidity = rng.gen_range(10i, 60i);
2424

2525
// this is slower than C because the current format! implementation is
2626
// very, very slow. Several orders of magnitude slower than glibc's

src/zmq/lib.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use std::{mem, ptr, str, slice};
1818
use std::fmt;
1919

2020
/// The ZMQ container that manages all the sockets
21-
type Context_ = *c_void;
21+
type Context_ = *mut c_void;
2222

2323
/// A ZMQ socket
24-
type Socket_ = *c_void;
24+
type Socket_ = *mut c_void;
2525

2626
static MsgSize_: uint = 48;
2727

@@ -30,26 +30,26 @@ type Msg_ = [c_char, ..MsgSize_];
3030

3131
#[link(name = "zmq")]
3232
extern {
33-
fn zmq_version(major: *c_int, minor: *c_int, patch: *c_int);
33+
fn zmq_version(major: *mut c_int, minor: *mut c_int, patch: *mut c_int);
3434

3535
fn zmq_ctx_new() -> Context_;
3636
fn zmq_ctx_destroy(ctx: Context_) -> c_int;
3737

3838
fn zmq_errno() -> c_int;
39-
fn zmq_strerror(errnum: c_int) -> *c_char;
39+
fn zmq_strerror(errnum: c_int) -> *const c_char;
4040

4141
fn zmq_socket(ctx: Context_, typ: c_int) -> Socket_;
4242
fn zmq_close(socket: Socket_) -> c_int;
4343

4444
fn zmq_getsockopt(socket: Socket_, opt: c_int, optval: *mut c_void, size: *mut size_t) -> c_int;
45-
fn zmq_setsockopt(socket: Socket_, opt: c_int, optval: *c_void, size: size_t) -> c_int;
45+
fn zmq_setsockopt(socket: Socket_, opt: c_int, optval: *const c_void, size: size_t) -> c_int;
4646

47-
fn zmq_bind(socket: Socket_, endpoint: *c_char) -> c_int;
48-
fn zmq_connect(socket: Socket_, endpoint: *c_char) -> c_int;
47+
fn zmq_bind(socket: Socket_, endpoint: *const c_char) -> c_int;
48+
fn zmq_connect(socket: Socket_, endpoint: *const c_char) -> c_int;
4949

5050
fn zmq_msg_init(msg: &Msg_) -> c_int;
5151
fn zmq_msg_init_size(msg: &Msg_, size: size_t) -> c_int;
52-
fn zmq_msg_data(msg: &Msg_) -> *u8;
52+
fn zmq_msg_data(msg: &Msg_) -> *const u8;
5353
fn zmq_msg_size(msg: &Msg_) -> size_t;
5454
fn zmq_msg_close(msg: &Msg_) -> c_int;
5555

@@ -163,25 +163,25 @@ impl Constants {
163163

164164
#[deriving(Clone, Eq, PartialEq)]
165165
pub enum Error {
166-
EACCES = posix88::EACCES,
167-
EADDRINUSE = posix88::EADDRINUSE,
168-
EAGAIN = posix88::EAGAIN,
169-
EBUSY = posix88::EBUSY,
170-
ECONNREFUSED = posix88::ECONNREFUSED,
171-
EFAULT = posix88::EFAULT,
172-
EHOSTUNREACH = posix88::EHOSTUNREACH,
173-
EINPROGRESS = posix88::EINPROGRESS,
174-
EINVAL = posix88::EINVAL,
175-
EMFILE = posix88::EMFILE,
176-
EMSGSIZE = posix88::EMSGSIZE,
177-
ENAMETOOLONG = posix88::ENAMETOOLONG,
178-
ENODEV = posix88::ENODEV,
179-
ENOENT = posix88::ENOENT,
180-
ENOMEM = posix88::ENOMEM,
181-
ENOTCONN = posix88::ENOTCONN,
182-
ENOTSOCK = posix88::ENOTSOCK,
183-
EPROTO = posix88::EPROTO,
184-
EPROTONOSUPPORT = posix88::EPROTONOSUPPORT,
166+
EACCES = posix88::EACCES as int,
167+
EADDRINUSE = posix88::EADDRINUSE as int,
168+
EAGAIN = posix88::EAGAIN as int,
169+
EBUSY = posix88::EBUSY as int,
170+
ECONNREFUSED = posix88::ECONNREFUSED as int,
171+
EFAULT = posix88::EFAULT as int,
172+
EHOSTUNREACH = posix88::EHOSTUNREACH as int,
173+
EINPROGRESS = posix88::EINPROGRESS as int,
174+
EINVAL = posix88::EINVAL as int,
175+
EMFILE = posix88::EMFILE as int,
176+
EMSGSIZE = posix88::EMSGSIZE as int,
177+
ENAMETOOLONG = posix88::ENAMETOOLONG as int,
178+
ENODEV = posix88::ENODEV as int,
179+
ENOENT = posix88::ENOENT as int,
180+
ENOMEM = posix88::ENOMEM as int,
181+
ENOTCONN = posix88::ENOTCONN as int,
182+
ENOTSOCK = posix88::ENOTSOCK as int,
183+
EPROTO = posix88::EPROTO as int,
184+
EPROTONOSUPPORT = posix88::EPROTONOSUPPORT as int,
185185
// magic number is EHAUSNUMERO + num
186186
ENOTSUP = 156384713,
187187
ENOBUFS = 156384715,
@@ -249,12 +249,12 @@ impl Error {
249249

250250
// Return the current zeromq version.
251251
pub fn version() -> (int, int, int) {
252-
let major = 0;
253-
let minor = 0;
254-
let patch = 0;
252+
let mut major = 0;
253+
let mut minor = 0;
254+
let mut patch = 0;
255255

256256
unsafe {
257-
zmq_version(&major, &minor, &patch);
257+
zmq_version(&mut major, &mut minor, &mut patch);
258258
}
259259

260260
(major as int, minor as int, patch as int)
@@ -727,7 +727,7 @@ macro_rules! setsockopt_num(
727727
unsafe {
728728
let size = mem::size_of::<$ty>() as size_t;
729729

730-
if -1 == zmq_setsockopt(sock, opt, (&value as *$ty) as *c_void, size) {
730+
if -1 == zmq_setsockopt(sock, opt, (&value as *const $ty) as *const c_void, size) {
731731
Err(errno_to_error())
732732
} else {
733733
Ok(())
@@ -746,7 +746,7 @@ fn setsockopt_bytes(sock: Socket_, opt: c_int, value: &[u8]) -> Result<(), Error
746746
let r = zmq_setsockopt(
747747
sock,
748748
opt,
749-
value.as_ptr() as *c_void,
749+
value.as_ptr() as *const c_void,
750750
value.len() as size_t
751751
);
752752

0 commit comments

Comments
 (0)