From 7a0564b6ca08dae0de3267016bf7ea5d7b70a92f Mon Sep 17 00:00:00 2001 From: Luca Versari Date: Sat, 21 Sep 2024 16:05:05 +0200 Subject: [PATCH] Cleanup: fix pull_request_checks.sh, add missing headers. Also add `#[deny(unsafe_code)]` to ensure that unsafe code is easier to audit, and missing_safety_doc, undocumented_unsafe_blocks, unsafe_op_in_unsafe_fn. --- Cargo.toml | 7 +++++++ ci/pull_request_checks.sh | 9 ++++----- jxl/Cargo.toml | 3 +++ jxl/src/headers/frame_header.rs | 5 +++++ jxl/src/image.rs | 5 +++++ jxl/src/lib.rs | 1 + jxl/src/render/mod.rs | 5 +++++ jxl_cli/Cargo.toml | 3 +++ jxl_headers_derive/Cargo.toml | 3 +++ 9 files changed, 36 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c567e28..f034c32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,3 +4,10 @@ debug = true [workspace] members = [ "jxl", "jxl_cli", "jxl_headers_derive"] resolver = "2" + +[workspace.lints.clippy] +missing_safety_doc = "deny" +undocumented_unsafe_blocks = "deny" + +[workspace.lints.rust] +unsafe_op_in_unsafe_fn = "deny" diff --git a/ci/pull_request_checks.sh b/ci/pull_request_checks.sh index b7d75c1..832e68f 100755 --- a/ci/pull_request_checks.sh +++ b/ci/pull_request_checks.sh @@ -9,15 +9,15 @@ MYDIR=$(dirname $(realpath "$0")) +TEXT_FILES='(Dockerfile.*|\.c|\.cc|\.cpp|\.gni|\.h|\.java|\.sh|\.m|\.py|\.ui|\.yml|\.rs)$' + set -u # Check for copyright / license markers. test_copyright() { local ret=0 local f - for f in $( - git ls-files | grep -E \ - '(Dockerfile.*|\.c|\.cc|\.cpp|\.gni|\.h|\.java|\.sh|\.m|\.py|\.ui|\.yml|\.rs)$'); do + for f in $(git ls-files .. | grep -E ${TEXT_FILES}); do if [[ "${f#third_party/}" == "$f" ]]; then # $f is not in third_party/ if ! head -n 10 "$f" | @@ -49,8 +49,7 @@ test_author() { # Check for git merge conflict markers. test_merge_conflict() { local ret=0 - TEXT_FILES='(\.cc|\.cpp|\.h|\.sh|\.m|\.py|\.md|\.txt|\.cmake|\.rs)$' - for f in $(git ls-files | grep -E "${TEXT_FILES}"); do + for f in $(git ls-files .. | grep -E "${TEXT_FILES}"); do if grep -E '^<<<<<<< ' "$f"; then echo "$f: Found git merge conflict marker. Please resolve." >&2 ret=1 diff --git a/jxl/Cargo.toml b/jxl/Cargo.toml index 5670508..ca26ffa 100644 --- a/jxl/Cargo.toml +++ b/jxl/Cargo.toml @@ -18,3 +18,6 @@ jxl_headers_derive = { path = "../jxl_headers_derive" } [features] debug_tools = [] + +[lints] +workspace = true diff --git a/jxl/src/headers/frame_header.rs b/jxl/src/headers/frame_header.rs index 8d44513..d70d124 100644 --- a/jxl/src/headers/frame_header.rs +++ b/jxl/src/headers/frame_header.rs @@ -1,3 +1,8 @@ +// Copyright (c) the JPEG XL Project Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + #![allow(clippy::excessive_precision)] use crate::{ diff --git a/jxl/src/image.rs b/jxl/src/image.rs index 5f3a10a..5e5374b 100644 --- a/jxl/src/image.rs +++ b/jxl/src/image.rs @@ -1,3 +1,8 @@ +// Copyright (c) the JPEG XL Project Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + use crate::error::{Error, Result}; mod private { diff --git a/jxl/src/lib.rs b/jxl/src/lib.rs index 578dd05..c9c0f47 100644 --- a/jxl/src/lib.rs +++ b/jxl/src/lib.rs @@ -3,6 +3,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +#![deny(unsafe_code)] pub mod bit_reader; pub mod container; pub mod entropy_coding; diff --git a/jxl/src/render/mod.rs b/jxl/src/render/mod.rs index df6b64b..5600cde 100644 --- a/jxl/src/render/mod.rs +++ b/jxl/src/render/mod.rs @@ -1,3 +1,8 @@ +// Copyright (c) the JPEG XL Project Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + use crate::{ error::Result, image::{ImageDataType, ImageRectMut}, diff --git a/jxl_cli/Cargo.toml b/jxl_cli/Cargo.toml index da1d78f..6dd6e60 100644 --- a/jxl_cli/Cargo.toml +++ b/jxl_cli/Cargo.toml @@ -5,3 +5,6 @@ edition = "2021" [dependencies] jxl = { path = "../jxl" } + +[lints] +workspace = true diff --git a/jxl_headers_derive/Cargo.toml b/jxl_headers_derive/Cargo.toml index f4dfbce..36d9be3 100644 --- a/jxl_headers_derive/Cargo.toml +++ b/jxl_headers_derive/Cargo.toml @@ -14,3 +14,6 @@ proc-macro2 = "1.0" proc-macro-error = "1.0" quote = "1.0" syn = { version = "1.0.45", features = ["extra-traits", "full"] } + +[lints] +workspace = true