Skip to content

Commit

Permalink
Cleanup: fix pull_request_checks.sh, add missing headers.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
veluca93 committed Sep 21, 2024
1 parent 1840959 commit 7a0564b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 5 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
9 changes: 4 additions & 5 deletions ci/pull_request_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" |
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions jxl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ jxl_headers_derive = { path = "../jxl_headers_derive" }

[features]
debug_tools = []

[lints]
workspace = true
5 changes: 5 additions & 0 deletions jxl/src/headers/frame_header.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand Down
5 changes: 5 additions & 0 deletions jxl/src/image.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
1 change: 1 addition & 0 deletions jxl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions jxl/src/render/mod.rs
Original file line number Diff line number Diff line change
@@ -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},
Expand Down
3 changes: 3 additions & 0 deletions jxl_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ edition = "2021"

[dependencies]
jxl = { path = "../jxl" }

[lints]
workspace = true
3 changes: 3 additions & 0 deletions jxl_headers_derive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7a0564b

Please sign in to comment.