Skip to main content

ExxonMobil Accuses California of Violating Its Free Speech

1 week 2 days ago
ExxonMobil has sued California, claiming the state's new climate disclosure laws violate its First Amendment rights by forcing the company to report greenhouse gas emissions and climate risks using standards it "fundamentally disagrees with." The Verge reports: The oil and gas company claims that the two laws in question aim to "embarrass" large corporations the state "believes are uniquely responsible for climate change" in order to push them to reduce their greenhouse gas emissions. There is overwhelming scientific consensus that greenhouse gas emissions from fossil fuels cause climate change by trapping heat on the planet. [...] Under laws the state passed in 2023, "ExxonMobil will be forced to describe its emissions and climate-related risks in terms the company fundamentally disagrees with," a complaint filed Friday says. The suit asks a US District Court to stop the laws from being enforced. [...] ExxonMobil's latest suit now says the company "understands the very real risks associated with climate change and supports continued efforts to address those risks," but that California's laws would force it "to describe its emissions and climate-related risks in terms the company fundamentally disagrees with." "These laws are about transparency. ExxonMobil might want to continue keeping the public in the dark, but we're ready to litigate vigorously in court to ensure the public's access to these important facts," Christine Lee, a spokesperson for the California Department of Justice, said in an email to The Verge.

Read more of this story at Slashdot.

BeauHD

CodeSOD: A Truly Bad Comparison

1 week 2 days ago

For C programmers of a certain age (antique), booleans represent a frustrating challenge. But with the addition of stdbool.h, we exited the world of needing to work hard to interact with boolean values. While some gotchas are still in there, your boolean code has the opportunity to be simple.

Mark's predecessor saw how simple it made things, and decided that wouldn't do. So that person went and wrote their own special way of comparing boolean values. It starts with an enum:

typedef enum exop_t { EXOP_NONE, EXOP_AND, EXOP_OR, EXOP_EQUAL, EXOP_NOTEQUAL, EXOP_LT, EXOP_GT, EXOP_LEQUAL, EXOP_GEQUAL, EXOP_ADD, EXOP_SUBTRACT, EXOP_MULTIPLY, EXOP_DIV, EXOP_MOD, EXOP_NEGATE, EXOP_UNION, EXOP_FILTER1, EXOP_FILTER2 };

Yes, they did write an enum to compare booleans. They also wrote not one, but two functions. Let's start with the almost sane one.

static bool compare_booleans (bool bool1, bool bool2, exop_t exop) { int32_t cmpresult; if ((bool1 && bool2) || (!bool1 && !bool2)) { cmpresult = 0; } else if (bool1) { cmpresult = 1; } else { cmpresult = -1; } return convert_compare_result(cmpresult, exop); }

This function takes two boolean values, and a comparison we wish to perform. Then, we test if they're equal, though the way we do that is by and-ing them together, then or-ing that with the and of their negations. If they're equal, cmpresult is set to zero. If they're not equal, and the first boolean is true, we set cmpresult to one, and finally to negative one.

Thus, we're just invented strcmp for booleans.

But then we call another function, which is super helpful, because it turns that integer into a more normal boolean value.

static boolean convert_compare_result (int32_t cmpresult, exop_t exop) { switch (exop) { case EXOP_EQUAL: return (cmpresult) ? FALSE : TRUE; case EXOP_NOTEQUAL: return (cmpresult) ? TRUE : FALSE; case EXOP_LT: return (cmpresult < 0) ? TRUE : FALSE; case EXOP_GT: return (cmpresult > 0) ? TRUE : FALSE; case EXOP_LEQUAL: return (cmpresult <= 0) ? TRUE : FALSE; case EXOP_GEQUAL: return (cmpresult >= 0) ? TRUE : FALSE; default: printf( "ERR_INTERNAL_VAL\n" ); return TRUE; } }

We switch based on the requested operation, and each case is its own little ternary. For equality comparisons, it requires a little bit of backwards logic- if cmpresult is non-zero (thus true), we need to return FALSE. Also note how our expression enum has many more options than convert_compare_result supports, making it very easy to call it wrong- and worse, it returns TRUE if you call it wrong.

At least they made booleans hard again. Who doesn't want to be confused about how to correctly check if two boolean values are the same?

It's worth noting that, for all this code, the rest of the code base never used anything but EXOP_EQUAL and EXOP_NOTEQUAL, because why would you do anything else on booleans? Every instance of compare_booleans could have been replaced with a much clearer == or != operator. Though what should really have been replaced was whoever wrote this code, preferably before they wrote it.

[Advertisement] Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!
Remy Porter