Fix warnings found by splint (#324)

* Fix warnings found by splint

* Ignore Win32 Builder warnings about possible data loss for integers.

* Fix Windows build warnings

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
Steve Karg
2022-08-17 23:23:26 -05:00
committed by GitHub
parent 8cddaa5881
commit c8671d54f7
15 changed files with 79 additions and 51 deletions
+2 -2
View File
@@ -114,8 +114,8 @@ static void bacnet_data_object_store(int index,
{
BACNET_DATA_OBJECT *object = NULL;
assert(rp_data);
assert(value);
assert(rp_data != NULL);
assert(value != NULL);
if ((index < BACNET_DATA_OBJECT_MAX) && (!value->context_specific)) {
object = &Object_Table[index];
switch (rp_data->object_property) {
+3 -1
View File
@@ -164,6 +164,7 @@ int cl_decode_apdu(uint8_t *apdu,
int dec_len = 0;
uint8_t tag_number = 0;
uint32_t len_value_type = 0;
uint32_t enum_value = 0;
BACNET_UNSIGNED_INTEGER unsigned_value = 0;
if (decode_is_context_tag(&apdu[dec_len], 0)) {
@@ -195,10 +196,11 @@ int cl_decode_apdu(uint8_t *apdu,
return BACNET_STATUS_REJECT;
}
len = decode_enumerated(
&apdu[dec_len], len_value_type, &bcl->Property_Identifier);
&apdu[dec_len], len_value_type, &enum_value);
if (len < 0) {
return BACNET_STATUS_REJECT;
}
bcl->Property_Identifier = enum_value;
dec_len += len;
if (decode_is_context_tag(&apdu[dec_len], 3)) {
len = decode_tag_number_and_value(
+8 -8
View File
@@ -121,7 +121,7 @@ void color_rgb_from_xy(uint8_t *red, uint8_t *green, uint8_t *blue,
float x = x_coordinate;
float y = y_coordinate;
float z = 1.0f - x - y;
float Y = brightness;
float Y = (float)brightness;
Y /= 255.0f;
float X = (Y / y) * x;
float Z = (Y / y) * z;
@@ -448,17 +448,17 @@ void color_rgb_from_temperature(
/* Red values below 6600 K are always 255 */
red = 255.0;
} else {
red = temperature_kelvin - 60;
red = (float)(temperature_kelvin - 60);
red = 329.698727446 * pow(red, -0.1332047592);
red = clamp(red, 0.0, 255.0);
}
/* Calculate Green */
if (temperature_kelvin <= 66) {
/* Green values below 6600 K */
green = temperature_kelvin;
green = (float)temperature_kelvin;
green = 99.4708025861 * log(green) - 161.1195681661;
} else {
green = temperature_kelvin - 60;
green = (float)(temperature_kelvin - 60);
green = 288.1221695283 * pow(green, -0.0755148492);
}
green = clamp(green, 0.0, 255.0);
@@ -470,17 +470,17 @@ void color_rgb_from_temperature(
/* Blue values below 1900 K */
blue = 0.0;
} else {
blue = temperature_kelvin - 10;
blue = (float)(temperature_kelvin - 10);
blue = 138.5177312231 * log(blue) - 305.0447927307;
blue = clamp(blue, 0, 255);
}
if (r) {
*r = red;
*r = (uint8_t)red;
}
if (g) {
*g = green;
*g = (uint8_t)green;
}
if (b) {
*b = blue;
*b = (uint8_t)blue;
}
}