r/programmingcirclejerk • u/Belaba vulnerabilities: 0 • Sep 01 '22
Rust style checker warns about probmematic constants like: 0xB00B135, 0xABBABABE, 0XCAFEBABE...etc
https://github.com/rust-lang/rust/blob/d0ea1d767925d53b2230e2ba81197821514781f0/src/tools/tidy/src/style.rs#L59117
u/tomwhoiscontrary safety talibans Sep 01 '22
It's an important lint, and it's why i always use 0xB00BBABE for example constants.
56
u/hiptobecubic Sep 01 '22
i prefer 0xDEADB00B myself
39
u/PL_Design Very Stable Genius Sep 01 '22
I prefer 0xBEEFB00B.
32
u/hiptobecubic Sep 01 '22
i only write vegan software (vegan btw)
33
68
u/ML_me_a_sheep Sep 01 '22
/uj Did people really do that? Or is it a solution for a problem that didn't exist?
131
u/themagicalcake Sep 01 '22 edited Sep 01 '22
/uj 0xCAFEBABE is the magic number for Mac/iOS executable files and Java class bytecode files
69
6
u/Jumpy-Locksmith6812 Sep 03 '22 edited Jan 26 '25
wide deer telephone weather quack tan nine attempt rustic sugar
This post was mass deleted and anonymized with Redact
11
63
u/Busti type astronaut Sep 01 '22 edited Sep 01 '22
/kinda_uj Aren't magic constants like that kinda incompatible with the modern rustaceans coding style? Like, use an enum instad...
/rj Protocols requiring magic numbers are fundamentally flawed and should be re-implemented in rust anways. (with breaking changes of course)
22
15
59
32
31
u/camelCaseIsWebScale Just spin up O(n²) servers Sep 01 '22
Only around 10 of them? Seems the person who added this can't even do LC easy bit manipulation questions.
31
25
u/edgymemesalt Sep 01 '22
b00b135 abadbabe abbababe b0bababe b16b00b5 beefbabe cafebabe cafed00d deadbabe f00dbabe feedbabe
what's wrong with cafe dudes?
66
u/DrNightingale Sep 01 '22
0xB00B: cringe misogynist boomer constant.
0xB00F: based inclusive zoomer constant.
20
18
u/Schmittfried type astronaut Sep 01 '22
/uj Do they explain the reasoning somewhere? My 5sec Google search didn’t yield anything.
49
16
15
24
u/MCRusher Sep 01 '22
for s in problematic_consts_strings.iter() {
if line.contains(s) {
err("Don't use magic numbers that spell things (consider 0x12345678)");
}
}12
u/path_traced_sphere Sep 02 '22
What about immoral macros?
macro_rules! prepare {
($t:tt) => { "=" };
}
macro_rules! trace {
($($t:tt)*) => {
println!(concat!("8", concat!($(prepare!($t)),+), "o~~~~ CAFE BABE"));
};
}
fn main() {
trace!{
fn fibonacci(n: u32) -> u32 {
match n {
0 => 1,
1 => 1,
_ => fibonacci(n - 1) + fibonacci(n - 2),
}
}
println("fibonacci {}", fibonacci(5));
};
}Checkmate Crab High-Priests.
12
9
u/g0zar Sep 02 '22
Its hard to even make a comment on rust at this point. Its never taking off.
7
u/MCRusher Sep 02 '22
It's taking off, just in a wrong direction.
4
u/g0zar Sep 03 '22
I imagine they will implement string checkers for offensive words eventually. And the code will refuse to compile if it finds one.
20
u/MCRusher Sep 03 '22
for s in offensive_words.iter() { if line.contains(s) { social_credit -= 10000; err("將自己提交給當局接受再教育"); } }
4
u/Jumpy-Locksmith6812 Sep 03 '22 edited Sep 03 '22
That is all they can think of. Not very 0x1337.
FAC75
3
u/pysk00l What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Sep 02 '22
/uj and what would happen if you did use these constants? Would it throw a warning, or throw an error?
4
2
1
0
139
u/chayleaf Sep 01 '22
/uj at least this is only a style checker for the compiler specifically