From 9135e0e5d9fa1349d8a2bdb10383b512efbf2c40 Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Thu, 9 Jan 2025 11:25:28 -0800 Subject: [PATCH 1/7] build: :technologist: Add more warning flags to makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50618747..1d042775 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ EXCLUDE_SRCDIRS+=$(SRCDIR)/tests C_STANDARD=gnu2x CXX_STANDARD=gnu++23 -WARNFLAGS+=-Wall -Wpedantic +WARNFLAGS+=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror EXTRA_CFLAGS= EXTRA_CXXFLAGS= From 0fe6163f6de3e8d7ba819aa2d4d005ee14115a0d Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:08:11 -0800 Subject: [PATCH 2/7] build: :rotating_light: Fix errors from deprecated llemu functions --- Makefile | 2 +- include/pros/llemu.hpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1d042775..3d1b7e80 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ EXCLUDE_SRCDIRS+=$(SRCDIR)/tests C_STANDARD=gnu2x CXX_STANDARD=gnu++23 -WARNFLAGS+=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror +WARNFLAGS+=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror -Wno-error=deprecated-declaration EXTRA_CFLAGS= EXTRA_CXXFLAGS= diff --git a/include/pros/llemu.hpp b/include/pros/llemu.hpp index 3a849846..fffa538f 100644 --- a/include/pros/llemu.hpp +++ b/include/pros/llemu.hpp @@ -50,6 +50,8 @@ namespace pros { #ifdef _PROS_INCLUDE_LIBLVGL_LLEMU_HPP namespace lcd { #else +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" namespace [[deprecated("Without liblvgl, LLEMU functions will not display anything. To install liblvgl run \"pros c install liblvgl\" in the PROS terminal.")]] lcd { #endif #pragma GCC diagnostic push @@ -144,4 +146,8 @@ namespace [[deprecated("Without liblvgl, LLEMU functions will not display anythi } // namespace lcd } // namespace pros +#ifndef _PROS_INCLUDE_LIBLVGL_LLEMU_HPP +#pragma GCC diagnostic pop +#endif + #endif // _PROS_LLEMU_HPP_ From 715ad6426254136e94b79e5e978ac643e25d430b Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:14:59 -0800 Subject: [PATCH 3/7] build: :rotating_light: Fix misspelled gcc option --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3d1b7e80..25ae9d78 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ EXCLUDE_SRCDIRS+=$(SRCDIR)/tests C_STANDARD=gnu2x CXX_STANDARD=gnu++23 -WARNFLAGS+=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror -Wno-error=deprecated-declaration +WARNFLAGS+=-Wall -Wextra -Wpedantic -Wconversion -Wsign-conversion -Werror -Wno-error=deprecated-declarations EXTRA_CFLAGS= EXTRA_CXXFLAGS= From bf306e8423962ce52870c7e3f49e6849c1ebe9ce Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:24:51 -0800 Subject: [PATCH 4/7] build: :rotating_light: Fix sign conversion error --- include/common/cobs.h | 2 +- src/common/cobs.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/common/cobs.h b/include/common/cobs.h index fe8c6a75..b772cc01 100644 --- a/include/common/cobs.h +++ b/include/common/cobs.h @@ -36,7 +36,7 @@ * * \return The number of bytes written */ -int cobs_encode(uint8_t* restrict dest, const uint8_t* restrict src, const size_t src_len, const uint32_t prefix); +size_t cobs_encode(uint8_t* restrict dest, const uint8_t* restrict src, const size_t src_len, const uint32_t prefix); /** * Same as cobs_encode() but doesn't write to an output buffer. Used to diff --git a/src/common/cobs.c b/src/common/cobs.c index 809b4c9f..9ef7c59a 100644 --- a/src/common/cobs.c +++ b/src/common/cobs.c @@ -55,7 +55,7 @@ size_t cobs_encode_measure(const uint8_t* restrict src, const size_t src_len, co return write_idx; } -int cobs_encode(uint8_t* restrict dest, const uint8_t* restrict src, const size_t src_len, const uint32_t prefix) { +size_t cobs_encode(uint8_t* restrict dest, const uint8_t* restrict src, const size_t src_len, const uint32_t prefix) { size_t read_idx = 0; size_t write_idx = 1; size_t code_idx = 0; From b47a7a37adcbe0e6557b88ba2f3513d252c0f219 Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 4 Feb 2025 11:32:42 -0800 Subject: [PATCH 5/7] build: :construction: Add -k flag to make invocation --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index fbf415e9..41ab862d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -29,7 +29,7 @@ jobs: - bash: pip install pros-cli displayName: Install CLI - bash: | - make template + make template -k mkdir -p artifacts cp template/*.zip artifacts displayName: Build template From 2bdcf18bfbbd6a76fb148da1119e4e0e4b1dc48d Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 1 Apr 2025 11:20:14 -0700 Subject: [PATCH 6/7] fix: :rotating_light: Fix sign conversion warnings in rotation/motor headers --- include/pros/motors.hpp | 2 +- include/pros/rotation.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/pros/motors.hpp b/include/pros/motors.hpp index a0782bd2..43d1be63 100644 --- a/include/pros/motors.hpp +++ b/include/pros/motors.hpp @@ -74,7 +74,7 @@ class Motor : public AbstractMotor, public Device { Motor(const std::int8_t port, const pros::v5::MotorGears gearset = pros::v5::MotorGears::invalid, const pros::v5::MotorUnits encoder_units = pros::v5::MotorUnits::invalid); - Motor(const Device& device) : Motor(device.get_port()){}; + Motor(const Device& device) : Device(device.get_port(), DeviceType::motor) {}; /// \name Motor movement functions /// These functions allow programmers to make motors move diff --git a/include/pros/rotation.hpp b/include/pros/rotation.hpp index 1e6dda9d..dbd77fed 100644 --- a/include/pros/rotation.hpp +++ b/include/pros/rotation.hpp @@ -55,7 +55,7 @@ class Rotation : public Device { */ Rotation(const std::int8_t port); - Rotation(const Device& device) : Rotation(device.get_port()){}; + Rotation(const Device& device) : Device(device.get_port(), DeviceType::rotation) {}; /** From dae8415489558b209618354bee587e18c34d9c13 Mon Sep 17 00:00:00 2001 From: ion098 <146852218+ion098@users.noreply.github.com> Date: Tue, 1 Apr 2025 11:40:26 -0700 Subject: [PATCH 7/7] fix: :rotating_light: Fix type/sign conversion warnings in port/vdml headers --- include/vdml/port.h | 4 ++-- include/vdml/vdml.h | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/include/vdml/port.h b/include/vdml/port.h index df93ba87..ea3ac7c9 100644 --- a/include/vdml/port.h +++ b/include/vdml/port.h @@ -22,8 +22,8 @@ #define get_ports(ports, smart_port, adi_port) \ { \ uint32_t uport = (uint32_t)ports; \ - smart_port = uport & SMART_PORT_MASK; \ - adi_port = uport >> SMART_PORT_BITS; \ + smart_port = (typeof(smart_port)) (uport & SMART_PORT_MASK); \ + adi_port = (typeof(adi_port)) (uport >> SMART_PORT_BITS); \ } static inline uint32_t merge_adi_ports(uint8_t smart_port, uint8_t adi_port) { diff --git a/include/vdml/vdml.h b/include/vdml/vdml.h index cb7248a7..9c3ca33f 100644 --- a/include/vdml/vdml.h +++ b/include/vdml/vdml.h @@ -25,13 +25,18 @@ extern "C" { #endif +// If a is unsigned, (typeof (a)) (-1) will be a really big positive value, and the +// entire comparison will become a >= a, to work around -Wtype-limits. Otherwise, +// the comparison will expand to a >= 0, as expected. +#define GTEQ_ZERO(a) ((a) >= __builtin_choose_expr( (typeof (a)) (-1) > 0, (a), 0)) + /** * Macro, returns true if the port is in range of user configurable ports, * false otherwise. */ -#define VALIDATE_PORT_NO(PORT) ((PORT) >= 0 && (PORT) < NUM_V5_PORTS) +#define VALIDATE_PORT_NO(PORT) (GTEQ_ZERO(PORT) && (PORT) < NUM_V5_PORTS) -#define VALIDATE_PORT_NO_INTERNAL(PORT) ((PORT) >= 0 && (PORT) < V5_MAX_DEVICE_PORTS) +#define VALIDATE_PORT_NO_INTERNAL(PORT) (GTEQ_ZERO(PORT) && (PORT) < V5_MAX_DEVICE_PORTS) /** * Macro that handles error checking, sanity checking, automatic registration, @@ -49,11 +54,11 @@ extern "C" { * The error code that return if error checking failed */ #define claim_port(port, device_type, error_code) \ - if (registry_validate_binding(port, device_type) != 0) { \ + if (registry_validate_binding((uint8_t) (port), device_type) != 0) { \ return error_code; \ } \ - v5_smart_device_s_t* device = registry_get_device(port); \ - if (!port_mutex_take(port)) { \ + v5_smart_device_s_t* device = registry_get_device((uint8_t) (port)); \ + if (!port_mutex_take((uint8_t) (port))) { \ errno = EACCES; \ return error_code; \ } @@ -111,7 +116,7 @@ int32_t claim_port_try(uint8_t port, v5_device_e_t type); * \return The rtn parameter */ #define return_port(port, rtn) \ - port_mutex_give(port); \ + port_mutex_give((uint8_t) (port)); \ return rtn; /**