Skip to content

Commit bf0bc6e

Browse files
committed
Removed some of the more ridiculous casts added after trying -Wconversion
1 parent 561c3bf commit bf0bc6e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

sxbp/begin_figure.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static sxbp_direction_t sxbp_change_line_direction(
5555
sxbp_direction_t current,
5656
sxbp_rotation_t turn
5757
) {
58-
return (sxbp_direction_t)((current + (sxbp_direction_t)turn) % 4);
58+
return (current + (sxbp_direction_t)turn) % 4;
5959
}
6060

6161
/*
@@ -72,13 +72,13 @@ static sxbp_length_t sxbp_next_length(
7272
assert(direction <= SXBP_LEFT);
7373
switch (direction % 4u) {
7474
case SXBP_UP:
75-
return (sxbp_length_t)labs(bounds.y_max - location.y) + 1;
75+
return labs(bounds.y_max - location.y) + 1;
7676
case SXBP_RIGHT:
77-
return (sxbp_length_t)labs(bounds.x_max - location.x) + 1;
77+
return labs(bounds.x_max - location.x) + 1;
7878
case SXBP_DOWN:
79-
return (sxbp_length_t)labs(bounds.y_min - location.y) + 1;
79+
return labs(bounds.y_min - location.y) + 1;
8080
case SXBP_LEFT:
81-
return (sxbp_length_t)labs(bounds.x_min - location.x) + 1;
81+
return labs(bounds.x_min - location.x) + 1;
8282
default:
8383
/*
8484
* NOTE: this case should never happen
@@ -158,7 +158,7 @@ sxbp_result_t sxbp_begin_figure(
158158
* the number of lines is the number of bits in the buffer
159159
* (byte count * 8) + 1 (for the extra starting line)
160160
*/
161-
figure->size = (sxbp_figure_size_t)(data->size * 8 + 1);
161+
figure->size = data->size * 8 + 1;
162162
// use default options if `options` is `NULL`
163163
if (options == NULL) {
164164
options = &SXBP_BEGIN_FIGURE_OPTIONS_DEFAULT;

sxbp/serialisation.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ static void sxbp_write_sxbp_data_line(
130130
) {
131131
size_t index = *start_index;
132132
// the leading 2 bits of the first byte are used for the direction
133-
buffer->bytes[index] = (uint8_t)(line.direction << 6u);
133+
buffer->bytes[index] = line.direction << 6u;
134134
// the next 6 bits of the first byte are used for the first 6 bits of length
135135
buffer->bytes[index] |= (line.length >> 24);
136136
// move on to the next byte
@@ -256,7 +256,7 @@ static void sxbp_read_sxbp_data_line(
256256
* handle first byte on it's own as we only need least 6 bits of it
257257
* bit mask and shift 3 bytes to left
258258
*/
259-
line->length = (sxbp_length_t)((buffer->bytes[index] & 0x3f) << 24); // 0x3f = 0b00111111
259+
line->length = (buffer->bytes[index] & 0x3f) << 24; // 0x3f = 0b00111111
260260
// next byte
261261
index++;
262262
// handle remaining 3 bytes in loop

sxbp/sxbp_internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ sxbp_bounds_t sxbp_get_bounds(const sxbp_figure_t* figure, size_t scale) {
7878
sxbp_move_location(
7979
&location,
8080
figure->lines[i].direction,
81-
(sxbp_length_t)(figure->lines[i].length * scale)
81+
figure->lines[i].length * scale
8282
);
8383
// update the bounds
8484
sxbp_update_bounds(location, &bounds);

0 commit comments

Comments
 (0)