WTF Bites
-
keep in mind the Windows API type BOOL is a std::uint32_t.
"Umm, actually..."
BOOL is a typedef of (signed) int, and it predates
std::uint32_t
, which wasn't added tostd
until C++11. Additionally, VisualStudio didn't have<stdint.h>
until like VS2013 or something, because that's a C90 header and C90 wasn't (isn't?) supported by VS.</>
-
I've also seen shit like
something ? true : false
.The next-level alternative to that is
!!something
.I've used that one in JavaScript/TypeScript a bunch. It's a pretty good shortcut to coerce something into a boolean.
-
I wrote a nasty JS script to inject a script into an iframe.
I had to write it again for another project the company has. I did a copy and paste of the JS into the MVC view.
Some guy from Support comes to me "I need to copy you work to Product X". I mentioned to my manager this will get out of hand.
So I now have to write it as a jQuery module, otherwise people will just copy and pasta my code until eternity.
-
@topspin said in WTF Bites:
I've also seen shit like
something ? true : false
.The next-level alternative to that is
!!something
.But that's a conversion to bool from a time when C didn't even have bool (i.e. conversion to int 0 or 1), used by people who know what they're doing. In my example
something
already is a bool, and people are just fucking clueless.
-
I've also seen shit like
something ? true : false
.In addition to what @cvi said, keep in mind the Windows API type
BOOL
is astd::uint32_t
.Assume, for the sake of discussion, a
bool something;
and that the people who wrote that never heard ofBOOL
.
-
otherwise people will just copy and pasta my code until eternity.
seems like a good way to disincentivise the spread of the nasty JS
-
I don't remember the exact context
I run into all the time with Windows
BOOL
andbool
.edit: d, of course.
-
@bb36e The nasty JS was some nasty iframe code. It was that or break web standards and make browsers do weird things when presented with the markup. I chose the iframe as a nicer solution (imagine that).
The vast majority of corp clients are on IE. While Chrome etc can deal with really junk markup ... IE won't.
-
something ? true : false
MSC++ has a warning for
(bool)something
(orbool(something)
orstatic_cast<bool>(something)
wheresomething
is a non-bool integral value:warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
but it does not show that for implicit conversion in a condition. So some people write it to avoid that.
-
That's pretty moronic for an explicit cast. The compiler is warning you about something you explicitly told it to do. Who thought that's a good idea?
But as I said, that'd be an explanation for people knowing what they're doing. What I was talking about was a
bool
context and people who don't understand why this is useless.
-
something ? true : false
MSC++ has a warning for
(bool)something
(orbool(something)
orstatic_cast<bool>(something)
wheresomething
is a non-bool integral value:warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
but it does not show that for implicit conversion in a condition. So some people write it to avoid that.
(something & 0x01)
-
That's pretty moronic for an explicit cast. The compiler is warning you about something you explicitly told it to do. Who thought that's a good idea?
Well, it warns you for implicit casts except in a condition too. So you have
return something
and it gives you the warning, so you try to silence it by sayingreturn bool(something)
and it keeps giving you the warning, so you curse and either rewrite it toreturn !!something
, which might be a bit surprising to code monkeys, or toreturn something ? true : false
, which is silly, but disables the warning.But if you have the guts, you go to the project settings and add a
/wd4800
, because that warning never made any sense in the first place (along with the dangerous warning 4018 and some more).(something & 0x01)
That's why a bad warning is actually dangerous.
-
(something & 0x01)
unsigned int something = 2; bool a = (bool) something; bool b = (bool) (something & 0x01); assert(a); assert(!b);
-
(something & 0x01)
unsigned int something = 2; bool a = (bool) something; bool b = (bool) (something & 0x01); assert(a); assert(!b);
#define TRUE 1 #define FALSE 0 #define 2 FILE_NOT_FOUND
-
keep in mind the Windows API type BOOL is a std::uint32_t.
"Umm, actually..."
BOOL is a typedef of (signed) int, and it predates
std::uint32_t
, which wasn't added tostd
until C++11. Additionally, VisualStudio didn't have<stdint.h>
until like VS2013 or something, because that's a C90 header and C90 wasn't (isn't?) supported by VS.</>
I meant that
BOOL
andstd::uint32_t
evaluate to the same integer type, or integer types with the same signedness and number of bits.I'd like to see what environment you're on whereBOOL
is signed, as it's certainly unsigned in my environment.
-
btw check out my blog: [here](C:\Documents and Settings\bb36e\Desktop\blog\1 (final) (3).doc)
-
@bb36e GitHub supports relative links like that for e.g. the README.md file. I've never seen
[url](title)
syntax though, that's backwards from markdown.
-
This post is deleted!
-
Hey Sony, I don't think you're supposed to advertise different products with the same name.
-
@anonymous234 That's not the name, they're just 1000 times more wireless than other noise cancelling headphones.
Also one is WF-1000X and the other is WI-1000X. Completely different, it's like night and day.
-
Major WTF of my day: So, we have this school management software to deal with user accounts, controlling PCs and all that jazz.
When they demoed the software, they pointed towards the ability to show a cleartext password to a pupil in case he forgot his password.
Yes, I know, but that's not the major yet. After all, I pointed it out and they disabled the "feature".
Today I was talking with a colleague about problems of the software and the issue of passwords came up, namely that I found it a bit byzantine how to reset a pupil's password in case the pupil forgot.
Her reaction: "Why would you need to reset the password? I just use this feature to show the password to the pupil!"
My answer: "You what now?"
-
@hungrier Also also, one is just wireless and the other is "Truly wireless".
-
@rhywden I think storing plaintext passwords is not as bad as people always assume. For a low-security environment it's probably worth the convenience.
-
@anonymous234 said in WTF Bites:
@rhywden I think storing plaintext passwords is not as bad as people always assume. For a low-security environment it's probably worth the convenience.
Found the NSA employee!
-
I don't think this will improve my salad.
-
@anonymous234 said in WTF Bites:
@rhywden I think storing plaintext passwords is not as bad as people always assume. For a low-security environment it's probably worth the convenience.
Sorry, but if they even didn't get that one right I shudder to think what the rest of their software must be like. Oh, wait...
Just to make my day complete, there's even an apostrophe for the plural of PC...
And don't ask me what those numbers mean. I have no clue, it's from a recent update they obviously didn't tell us about.
-
With the propensity for people to reuse passwords, it is just as bad if not worse than people assume.
-
I don't think this will improve my salad.
Won't anyone think of the Vegans
Yeah, didn't think so.
-
@rhywden If you uninstall the update from one PC, all 13 will have upgraded.
Filed under: the mathematician's answer
-
I'd like to see what environment you're on where BOOL is signed, as it's certainly unsigned in my environment.
This is in Visual Studio 2017. I created an empty project, and just included <windows.h>. It's the same for x86 and x64, too.
Visual Studio 2015. Same thing.
For Visual Studio 2013, I'd have to start a different machine, so I CBA.
Either way, I'm wondering what environment you're on.... Especially considering the third entry in the table over here (MSDN).
-
@bb36e GitHub supports relative links like that for e.g. the README.md file. I've never seen
[url](title)
syntax though, that's backwards from markdown.No it's not. link
-
@anonymous234 said in WTF Bites:
@rhywden I think storing plaintext passwords is not as bad as people always assume. For a low-security environment it's probably worth the convenience.
No.
If it's 'secure' enough to require passwords, then it needs to be secure enough to store them safely.
Besides feature creep results in systems that were 'low-security' (whatever that's measuring) being (to continue the theme) 'high-security.'
-
@cvi well my memory is terrible, you're absolutely right. I should've double checked before but it is indeed a signed 32-bit integer for me as well. Sorry for the trouble.
-
-
@tsaukpaetra
BOOL
is assuredly notdouble
.
-
@pie_flavor said in WTF Bites:
@tsaukpaetra
BOOL
is assuredly notdouble
.
-
@homobalkanus said in WTF Bites:
switch (event.getType()) { case NodeDataChanged: //code break; }
That's it. no default, no other case statements. A simple if statement is not good enough for this developer -.-
With the compiler settings I use, that would be useful in one case and one case only:
An enumeration has one possible value and you want a compiler error if someone adds another possible value and doesn't update the switch.
-
@timebandit No, if it was a boolean the code would read
if (something == true)
That construct is actually useful in C# with the
bool?
type. That could also be written assomething ?? false
but that's less straightforward.
-
A neo-Nazi and Holocaust denier garnered more than 20,000 votes and won the Republican primary in the 3rd Congressional District of Illinois on Tuesday night after running uncontested.
Well, it's kind of hard not to win when you're running unopposed. As to why there no other Republicans running, it's probably because the 3rd District is a suburb of Chicago that has elected a Democrat in 24 of the last 25 elections; therefore, it's rather pointless to try. So, although Jones won the primary, he has about as much chance of being elected to Congress as wild tropical orchids have of blooming in the middle of a Chicago winter. It's also rather interestingly gerrymandered:
-
@anonymous234 said in WTF Bites:
@rhywden I think storing plaintext passwords is not as bad as people always assume. For a low-security environment it's probably worth the convenience.
The risk of bored students getting hold of the database and fucking with eachother just for shits and giggles is rather high.
If someone fails the utterly low bar of not storing passwords in plain text, something that has been regarded as dumb in most concievable ways for a decade or two by pretty much everyone, you can bet pretty much anything that the rest of the security features are lacking.
-
@hardwaregeek said in WTF Bites:
running unopposed
I submitted an absentee ballot a few days ago (Wisconsin's 1st district).
The things being voted on fall into six categories:
- Supreme court justice
- County executive
- Pick one person from this list of one people
- Pick two people from this list of two people
- Pick one person from this list of one people with a typo in their name
- Should we get rid of the County Treasurer position, which has no responsibilities after the last person to be elected to that position fulfilled their promise to eliminate the position's responsibilities?
-
@blakeyrat said in WTF Bites:
Once had a user reporting that data loaded into the grid weren't complete, some periods are missing. There was a scroll bar on the right hand side of the grid. The data she wanted was outside of the viewport.
That's a software bug.
One bug report regarding this, no one's ever had problems.
Yeah, sometimes the user's the problem.That means it's a low-priority software bug. That does not mean there's no possibility of improving the software.
That improvement can be implemented doesn't mean that there's a bug.
Honestly, how would you "fix" this particular issue?
-
For Visual Studio 2013
The typedefs can't change for compatibility reason. Therefore pretty certainly they never changed since introduced back in Windows 2 or some such version.
-
@tsaukpaetra said in WTF Bites:
Sorry for the trouble.
Hey, at least you didn't make it double!
-
The typedefs can't change for compatibility reason.
There's that. While people joke about Microsoft's tendency to invent and immediately deprecate APIs and framworks, the C Win32 API has been around for a looong time (as you say), and they've maintained backwards compatibility for the most part.
(I mostly included 2015 and 2017 because I had them running anyway. The link to MSDN was all that was needed, in theory.)
-
@pie_flavor said in WTF Bites:
@tsaukpaetra
BOOL
is assuredly notdouble
.That would be wasteful.
float
is more than enough.
-
@ben_lubar said in WTF Bites:
Should we get rid of the County Treasurer position, which has no responsibilities after the last person to be elected to that position fulfilled their promise to eliminate the position's responsibilities?
How you do that? Spend all the county's money for all perpetuity?
-
Got the standard 'you must reset your password in the next 30 days email' a while back, and I've been steadily putting it off. I thought it was asking me for my current password when it was actually asking me for my new one, and, well, it may say that they require you to use a different one each time, but it doesn't seem like it's actually enforced.
-
@pie_flavor said in WTF Bites:
Got the standard 'you must reset your password in the next 30 days email' a while back, and I've been steadily putting it off. I thought it was asking me for my current password when it was actually asking me for my new one, and, well, it may say that they require you to use a different one each time, but it doesn't seem like it's actually enforced.
It looks like they didn't read the newest version of NIST Special Publication 800-63B - Digital Identity Guidelines - Authentication and Lifecycle Management (in particular section 5.1.1.2)
They really no longer recommend changing passwords unless there's a chance of a compromised password:Verifiers SHOULD NOT require memorized secrets to be changed arbitrarily (e.g., periodically). However, verifiers SHALL force a change if there is evidence of compromise of the authenticator.
Is there a possibility to do a Reply All?
-
@pie_flavor said in WTF Bites:
@tsaukpaetra
BOOL
is assuredly notdouble
.With Win32 you can never be sure.