Skip to content

Commit

Permalink
Fix warnings (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
sppalkia authored Jul 2, 2019
1 parent 0bf6c79 commit 2a628e6
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 26 deletions.
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
When you contribute code, you affirm that the contribution is your original work and that you license the work to the project under the project's open source license. Whether or not you state this explicitly, by submitting any copyrighted material via pull request, email, or other means you agree to license the material under the project's open source license and warrant that you have the legal authority to do so.

## Tests

Weld has several integration and doctests, controlled via `cargo`. Travis CI
ensures that new patches do not fail existing tests. To run these tests locally:

```
cargo test
```

## Formatting

Weld uses `clippy` and `rustfmt` for lints and format checks respectively.
Travis CI checks to ensure that all lints pass and that code is formatted in
accordance with `rustfmt`. To check this before submitting code, run the
following:

```
cargo clippy
cargo fmt -- --check
```
14 changes: 7 additions & 7 deletions weld-capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use weld;

use libc::{c_char, c_void, int64_t, uint64_t};
use libc::{c_char, c_void};

use std::ffi::CStr;
use std::ptr;
Expand Down Expand Up @@ -96,10 +96,10 @@ pub unsafe extern "C" fn weld_context_new(conf: weld_conf_t) -> weld_context_t {
/// Gets the memory allocated by a Weld context.
///
/// This includes all live memory allocated in the given context.
pub unsafe extern "C" fn weld_context_memory_usage(context: weld_context_t) -> int64_t {
pub unsafe extern "C" fn weld_context_memory_usage(context: weld_context_t) -> i64 {
let context = context as *mut weld::WeldContext;
let context = &*context;
context.memory_usage() as int64_t
context.memory_usage()
}

#[no_mangle]
Expand Down Expand Up @@ -177,10 +177,10 @@ pub extern "C" fn weld_value_new(data: *const c_void) -> weld_value_t {
/// Returns the Run ID of the value.
///
/// If this value was not returned by a Weld program, this function returns `-1`.
pub unsafe extern "C" fn weld_value_run(value: weld_value_t) -> int64_t {
pub unsafe extern "C" fn weld_value_run(value: weld_value_t) -> i64 {
let value = value as *mut weld::WeldValue;
let value = &*value;
value.run_id().unwrap_or(-1) as int64_t
value.run_id().unwrap_or(-1)
}

#[no_mangle]
Expand Down Expand Up @@ -311,7 +311,7 @@ pub extern "C" fn weld_error_new() -> weld_error_t {
/// Returns the error code for a Weld error.
///
/// This function is a wrapper for `WeldError::code`.
pub unsafe extern "C" fn weld_error_code(err: weld_error_t) -> uint64_t {
pub unsafe extern "C" fn weld_error_code(err: weld_error_t) -> u64 {
let err = err as *mut weld::WeldError;
let err = &*err;
err.code() as _
Expand Down Expand Up @@ -357,6 +357,6 @@ pub unsafe extern "C" fn weld_load_library(filename: *const c_char, err: weld_er
///
/// This function is ignored if it has already been called once, or if some other code in the
/// process has initialized logging using Rust's `log` crate.
pub extern "C" fn weld_set_log_level(level: uint64_t) {
pub extern "C" fn weld_set_log_level(level: u64) {
weld::set_log_level(level.into())
}
2 changes: 0 additions & 2 deletions weld/src/ast/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ impl NewExpr for Expr {

fn new_literal(kind: LiteralKind) -> WeldResult<Expr> {
use crate::ast::LiteralKind::*;
use crate::ast::Type::Scalar;

let ty = match kind {
BoolLiteral(_) => Scalar(ScalarKind::Bool),
I8Literal(_) => Scalar(ScalarKind::I8),
Expand Down
1 change: 0 additions & 1 deletion weld/src/codegen/llvm2/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ impl BuilderExpressionGen for LlvmGenerator {
}
DictMerger(ref key, ref val, ref binop) => {
use self::hash::*;
use crate::ast::Type::Scalar;

// Build the default value that we upsert if the key is not present in the
// dictionary yet.
Expand Down
1 change: 0 additions & 1 deletion weld/src/codegen/llvm2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1633,7 +1633,6 @@ impl LlvmGenerator {
}
}
Crash => {
use crate::runtime::WeldRuntimeErrno;
let errno = self.i64(WeldRuntimeErrno::Unknown as i64);
self.intrinsics.call_weld_run_set_errno(
context.builder,
Expand Down
3 changes: 0 additions & 3 deletions weld/src/codegen/llvm2/numeric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ impl NumericExpressionGen for LlvmGenerator {
ctx: &mut FunctionContext<'_>,
statement: &Statement,
) -> WeldResult<()> {
use self::UnaryOpSupport;
use crate::ast::Type::{Scalar, Simd};
use crate::sir::StatementKind::UnaryOp;
if let UnaryOp { op, ref child } = statement.kind {
Expand Down Expand Up @@ -237,7 +236,6 @@ impl NumericExpressionGen for LlvmGenerator {
ctx: &mut FunctionContext<'_>,
statement: &Statement,
) -> WeldResult<()> {
use self::llvm_sys::LLVMIntPredicate::LLVMIntEQ;
use crate::sir::StatementKind::Not;
if let Not(ref child) = statement.kind {
let value = self.load(ctx.builder, ctx.get_value(child)?)?;
Expand Down Expand Up @@ -296,7 +294,6 @@ impl NumericExpressionGen for LlvmGenerator {
ctx: &mut FunctionContext<'_>,
statement: &Statement,
) -> WeldResult<()> {
use crate::ast::BinOpKind;
use crate::ast::Type::{Scalar, Simd, Struct, Vector};
use crate::sir::StatementKind::BinOp;
if let BinOp {
Expand Down
3 changes: 0 additions & 3 deletions weld/src/codegen/llvm2/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,6 @@ impl DeHelper for LlvmGenerator {
buffer: LLVMValueRef,
position: LLVMValueRef,
) -> WeldResult<(LLVMValueRef, LLVMValueRef)> {
use crate::codegen::llvm2::vector::VectorExt;

let size = self.size_of(ty);
let pointer = self.gen_at(builder, &SER_TY, buffer, position)?;

Expand All @@ -554,7 +552,6 @@ impl DeHelper for LlvmGenerator {
buffer: LLVMValueRef,
position: LLVMValueRef,
) -> WeldResult<LLVMValueRef> {
use crate::codegen::llvm2::vector::VectorExt;
let elem_size = self.size_of(LLVMGetElementType(LLVMTypeOf(ptr)));
let size = LLVMBuildNSWMul(builder, size, elem_size, c_str!(""));

Expand Down
1 change: 0 additions & 1 deletion weld/src/optimizer/transforms/cse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ impl Cse {
expr: &mut Expr,
bindings: &mut HashMap<Expr, Symbol>,
) {
use self::UseCse;
expr.transform_up(&mut |ref mut e| {
if !e.use_cse() {
return None;
Expand Down
1 change: 0 additions & 1 deletion weld/src/optimizer/transforms/inliner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ fn getfield_on_symbol(expr: &Expr, sym: &Symbol) -> Option<u32> {
///
/// This switches the true condition and the false condition.
pub fn simplify_branch_conditions(expr: &mut Expr) {
use crate::ast::BinOpKind;
use crate::ast::LiteralKind::BoolLiteral;
expr.uniquify().unwrap();
expr.transform_up(&mut |ref mut expr| {
Expand Down
9 changes: 3 additions & 6 deletions weld/src/runtime/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ pub unsafe extern "C" fn weld_init() {

#[no_mangle]
/// Returns a new runtime handle.
pub unsafe extern "C" fn weld_runst_init(
nworkers: int32_t,
memlimit: int64_t,
) -> WeldRuntimeContextRef {
pub unsafe extern "C" fn weld_runst_init(nworkers: i32, memlimit: i64) -> WeldRuntimeContextRef {
Box::into_raw(Box::new(WeldRuntimeContext::new(nworkers, memlimit)))
}

Expand All @@ -33,7 +30,7 @@ pub unsafe extern "C" fn weld_runst_release(run: WeldRuntimeContextRef) {

#[no_mangle]
/// Allocate memory within the provided context.
pub unsafe extern "C" fn weld_runst_malloc(run: WeldRuntimeContextRef, size: int64_t) -> Ptr {
pub unsafe extern "C" fn weld_runst_malloc(run: WeldRuntimeContextRef, size: i64) -> Ptr {
let run = &mut *run;
run.malloc(size)
}
Expand All @@ -45,7 +42,7 @@ pub unsafe extern "C" fn weld_runst_malloc(run: WeldRuntimeContextRef, size: int
pub unsafe extern "C" fn weld_runst_realloc(
run: WeldRuntimeContextRef,
ptr: Ptr,
newsize: int64_t,
newsize: i64,
) -> Ptr {
let run = &mut *run;
run.realloc(ptr, newsize)
Expand Down
2 changes: 1 addition & 1 deletion weld/src/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod ffi;

use self::ffi::*;

use libc::{c_char, int32_t, int64_t};
use libc::c_char;
use std::alloc::System as Allocator;

use fnv::FnvHashMap;
Expand Down

0 comments on commit 2a628e6

Please sign in to comment.