Skip to content

Commit

Permalink
chore: forbid unsafe code (#131)
Browse files Browse the repository at this point in the history
Writing unsafe code is difficult and should generally be avoided. When
using unsafe code is necessary, it is ideal if it can be delegated to
public crates that can be tested and audited by multiple developers.

This commit consistently forbids unsafe code in crates where it is not
necessary to serve as a reminder that it should probably be avoided in
the future and that the intention of this project is to provide safe
abstractions that allow application authors to avoid unsafe code in
their applications.

`apps-aarch64.checksum`:
- I think the reason why the checksums change is that the line numbers
  have changed.
  • Loading branch information
apljungquist authored Nov 15, 2024
1 parent 40446c2 commit 185f935
Show file tree
Hide file tree
Showing 24 changed files with 34 additions and 12 deletions.
22 changes: 11 additions & 11 deletions apps-aarch64.checksum
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
0018f1c3b46545bebbef794b68900c254a7785e7 target-aarch64/acap/axstorage_example_0_0_0_aarch64.eap
10227865e8dadfeeda0e4a3c1a0d88ed18bc019a target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
c11772e7188d741a7a13225dbb14c8e059aee060 target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
51f9e2ce6cfc81264afa310c9c51ee05ff45666d target-aarch64/acap/embedded_web_page_0_0_0_aarch64.eap
da794d700cc407d5692e7387e5f8af3a56c29bea target-aarch64/acap/hello_world_0_0_0_aarch64.eap
df34073ade39bb4331ae5cc550616f41a7dc0efa target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
fc9fb4feab60aee66ae038003cabc1c84ac095e1 target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
325db11bbaf07e7c0e89cb0bf2f336a1ee68d462 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
877e8ab707cd7652a5a15243b9c934a3941168c5 target-aarch64/acap/send_event_1_0_0_aarch64.eap
aaa472d88219f8117020b76c2f37906f25f49d14 target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
f7b952e221c94d5e53ee3faac156c0e7e7a91477 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
12a30609c7fa463e1e8d0405665d2aa17d4349c4 target-aarch64/acap/axstorage_example_0_0_0_aarch64.eap
6db963922ca2ceb25715bbdb6445b504c307d432 target-aarch64/acap/bounding_box_example_0_0_0_aarch64.eap
f99e344e5bf6fc4cd59715b9a4b784a83df27342 target-aarch64/acap/consume_analytics_metadata_0_0_0_aarch64.eap
ad1142937ed6e2d4f2a1f4cb0fdae721a0744750 target-aarch64/acap/embedded_web_page_0_0_0_aarch64.eap
f47872232e0f2cd4ace9e2e77b07cafb431cbe73 target-aarch64/acap/hello_world_0_0_0_aarch64.eap
b7481baf218b83da3f4cb90229eaa3b15d61808e target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
9d205dbde1b7144d30fb4c5a45fcaef93cb12810 target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
ed84b4b9ae09256dcef1a7287cd802e39c8b6a92 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
329f130017b7d25555415a2af2d9aa40c3b560c9 target-aarch64/acap/send_event_1_0_0_aarch64.eap
21de4a45004863178cd692c9bc4875bba8fef0a2 target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
5a533b71d01edb65d15751dd93fa153f5ef343ea target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
2 changes: 1 addition & 1 deletion apps-aarch64.filesize
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
2003 target-aarch64/acap/hello_world_0_0_0_aarch64.eap
2135 target-aarch64/acap/inspect_env_0_0_0_aarch64.eap
2060 target-aarch64/acap/licensekey_handler_0_0_0_aarch64.eap
10426 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
10425 target-aarch64/acap/reverse_proxy_0_0_0_aarch64.eap
4087 target-aarch64/acap/send_event_1_0_0_aarch64.eap
859 target-aarch64/acap/using_a_build_script_0_0_0_aarch64.eap
11361 target-aarch64/acap/vapix_access_0_0_0_aarch64.eap
1 change: 1 addition & 0 deletions apps/axstorage_example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! An example of how to handle storage disks using the Edge Storage API.

use std::{
Expand Down
1 change: 1 addition & 0 deletions apps/bounding_box_example/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! An example of how to draw bounding boxes using the Bounding Box API.

use std::{
Expand Down
1 change: 1 addition & 0 deletions apps/consume_analytics_metadata/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! An example app that subscribes to analytics scene description data using [`mdb`].

use std::{ffi::CStr, process::abort, thread::sleep, time::Duration};
Expand Down
1 change: 1 addition & 0 deletions apps/embedded_web_page/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple example application demonstrating how to bundle an embedded web page.
//!
//! All applications require a program, but for this example it doesn't need to do anything,
Expand Down
1 change: 1 addition & 0 deletions apps/hello_world/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple hello world application
//!
//! This app demonstrates:
Expand Down
1 change: 1 addition & 0 deletions apps/inspect_env/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple app that inspects the environment it runs in

use std::{collections::HashMap, env, io::IsTerminal};
Expand Down
1 change: 1 addition & 0 deletions apps/licensekey_handler/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple example application demonstrating how the licensekey crate may be used

use std::{
Expand Down
1 change: 1 addition & 0 deletions apps/reverse_proxy/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! An example of how to run a webserver

use std::{
Expand Down
1 change: 1 addition & 0 deletions apps/send_event/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! An example of how to send an ONVIF event periodically.
//!
//! The audience for this example is users who are familiar with the C APIs and have existing code
Expand Down
1 change: 1 addition & 0 deletions apps/using_a_build_script/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple example application demonstrating how to use a build script to generate files
//! dynamically.
//!
Expand Down
1 change: 1 addition & 0 deletions apps/vapix_access/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
//! A simple app that uses a VAPIX service account to access VAPIX APIs.

use std::time::Duration;
Expand Down
1 change: 1 addition & 0 deletions crates/acap-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
/// Wrapper around the ACAP SDK, in particular `acap-build`.
use std::os::unix::fs::PermissionsExt;
use std::{
Expand Down
1 change: 1 addition & 0 deletions crates/acap-logging/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
#![allow(clippy::needless_doctest_main)]
#![doc = include_str!("../README.md")]
use std::{env, io::IsTerminal};
Expand Down
1 change: 1 addition & 0 deletions crates/acap-ssh-utils/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
mod acap;

use std::{
Expand Down
1 change: 1 addition & 0 deletions crates/acap-ssh-utils/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{env, fs::File, path::PathBuf};

use acap_ssh_utils::{patch_package, run_other, run_package};
Expand Down
1 change: 1 addition & 0 deletions crates/acap-vapix/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]

use std::{
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-acap-build/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
#![doc=include_str!("../README.md")]

use std::{
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-acap-build/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::fs::File;

use cargo_acap_build::{get_cargo_metadata, AppBuilder, Architecture};
Expand Down
1 change: 1 addition & 0 deletions crates/cargo-acap-sdk/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{ffi::OsString, fs::File, str::FromStr};

use acap_vapix::{applications_control, basic_device_info, HttpClient};
Expand Down
1 change: 1 addition & 0 deletions crates/device-manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]

mod initialization;
Expand Down
1 change: 1 addition & 0 deletions crates/device-manager/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{env, fs::File};

use clap::{Parser, Subcommand};
Expand Down
1 change: 1 addition & 0 deletions crates/fleet-manager/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use std::{ffi::OsString, path::PathBuf};

use anyhow::Context;
Expand Down

0 comments on commit 185f935

Please sign in to comment.