Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
Please clippy.
Browse files Browse the repository at this point in the history
  • Loading branch information
picnoir committed Oct 8, 2023
1 parent e37dc77 commit 0eaa3ad
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub fn disable_internal_nscd() {
}
}

mod ffi {
mod glibcffi {
use nix::libc;
extern "C" {
pub fn gethostbyname2_r (
Expand Down Expand Up @@ -178,7 +178,7 @@ pub fn gethostbyname2_r(name: String, af: libc::c_int) -> anyhow::Result<Hostent
let mut hostent_result = ptr::null_mut();
let ret: i32 = loop {
let ret = unsafe {
ffi::gethostbyname2_r(
glibcffi::gethostbyname2_r(
name.as_ptr(),
af,
&mut ret_hostent,
Expand Down
8 changes: 4 additions & 4 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ use std::os::unix::ffi::OsStrExt;

use anyhow::{bail, Context, Result};
use atoi::atoi;
use dns_lookup::{getaddrinfo, getnameinfo, AddrInfoHints};
use nix::libc::{AF_INET6, NI_NUMERICSERV, SOCK_STREAM};
use dns_lookup::getnameinfo;
use nix::libc::NI_NUMERICSERV;
use nix::sys::socket::AddressFamily;
use nix::unistd::{getgrouplist, Gid, Group, Uid, User};
use slog::{debug, error, Logger};
Expand Down Expand Up @@ -433,15 +433,15 @@ impl Host {
} else {
16
},
h_addr_list_cnt: num_addrs as i32,
h_addr_list_cnt: num_addrs,
error: if has_addrs {
0
} else {
protocol::H_ERRNO_HOST_NOT_FOUND
},
};

let total_len = 4 * 8 + hostname_c_string_len as i32 + buf_addrs.len() as i32;
let total_len = 4 * 8 + hostname_c_string_len + buf_addrs.len() as i32;
let mut buf = Vec::with_capacity(total_len as usize);

// add header
Expand Down
14 changes: 7 additions & 7 deletions src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ impl HstResponseHeader {
}

/// Return the serialized header as vector of bytes
pub fn to_vec(&self) -> Vec<u8> {
pub fn to_vec(self) -> Vec<u8> {
self.as_slice().to_vec()
}

Expand All @@ -275,20 +275,20 @@ impl HstResponseHeader {
found: 0,
h_name_len: 0,
h_aliases_cnt: 0,
h_addrtype: -1 as i32,
h_length: -1 as i32,
h_addrtype: -1,
h_length: -1,
h_addr_list_cnt: 0,
error: H_ERRNO_HOST_NOT_FOUND as i32,
error: H_ERRNO_HOST_NOT_FOUND,
};

pub const ERRNO_NETDB_INTERNAL: Self = Self {
version: VERSION,
found: 0,
h_name_len: 0,
h_aliases_cnt: 0,
h_addrtype: -1 as i32,
h_length: -1 as i32,
h_addr_list_cnt: H_ERRNO_NETDB_INTERNAL as i32,
h_addrtype: -1,
h_length: -1,
h_addr_list_cnt: H_ERRNO_NETDB_INTERNAL,
error: 0,
};
}
Expand Down

0 comments on commit 0eaa3ad

Please sign in to comment.