Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix undefined signed 32-bit integer signed shift left by 31 #3318

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/emc/usr_intf/emcsched.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define MAX_PRIORITY 0x80000000
#define POLYNOMIAL 0xD8 /* 11011 followed by 0's */
#define WIDTH (8 * sizeof(crc))
#define TOPBIT (1 << (WIDTH - 1))
#define TOPBIT (1u << (WIDTH - 1))

typedef uint32_t crc;
crc crcTable[256];
Expand Down
2 changes: 1 addition & 1 deletion src/hal/drivers/hal_ppmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,7 @@ static rtapi_u32 block(int min, int max)

mask = 0;
for ( n = min ; n <= max ; n++ ) {
mask |= ( 1 << n );
mask |= ( 1u << n );
}
return mask;
}
Expand Down
4 changes: 2 additions & 2 deletions src/hal/drivers/mesa-hostmot2/hm2_rpspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -916,11 +916,11 @@ static void inline gpio_pull(unsigned pin, uint32_t pud)
reg_wr(&gpio->gppud, pud);
waste_150_cycles();
if(pin <= 31) {
reg_wr(&gpio->gppudclk0, 1 << pin);
reg_wr(&gpio->gppudclk0, 1u << pin);
waste_150_cycles();
reg_wr(&gpio->gppudclk0, 0);
} else if(pin <= 53) {
reg_wr(&gpio->gppudclk1, 1 << (pin - 32));
reg_wr(&gpio->gppudclk1, 1u << (pin - 32));
waste_150_cycles();
reg_wr(&gpio->gppudclk1, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/hal/drivers/mesa-hostmot2/pwmgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ void hm2_pwmgen_prepare_tram_write(hostmot2_t *hm2) {
}
hm2->pwmgen.pwm_value_reg[i] = register_value * 65536;
if (scaled_value < 0) {
hm2->pwmgen.pwm_value_reg[i] |= (1 << 31);
hm2->pwmgen.pwm_value_reg[i] |= (1u << 31);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hal/drivers/mesa-hostmot2/spix_rpi3.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,11 @@ static void gpio_pull(unsigned pin, uint32_t pud)
reg_wr(&gpio->gppud, pud);
waste_150_cycles();
if(pin <= 31) {
reg_wr(&gpio->gppudclk0, 1 << pin);
reg_wr(&gpio->gppudclk0, 1u << pin);
waste_150_cycles();
reg_wr(&gpio->gppudclk0, 0);
} else if(pin <= 53) {
reg_wr(&gpio->gppudclk1, 1 << (pin - 32));
reg_wr(&gpio->gppudclk1, 1u << (pin - 32));
waste_150_cycles();
reg_wr(&gpio->gppudclk1, 0);
}
Expand Down
Loading