Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
mmkay
Oct 21, 2010

Subjunctive posted:

Still better than strncpy, which nobody should ever use.

Why is it so bad? Is it the fact that it won't null terminate a string over the specified size the problem, or what?

Adbot
ADBOT LOVES YOU

mmkay
Oct 21, 2010

Rocko Bonaparte posted:

Has anybody ever considered trying to add a fake device in QEMU for integration/regression testing of drivers for the real device? I was curious how much of a thing that is.

Yes, but it was a type of NVMe device, for which adding the extra tidbits/logic was pretty trivial.

mmkay
Oct 21, 2010

Ihmemies posted:

Multiple people have said this so far but I still have no idea. I never spot my own mistakes and rarely learn from them so most likely this one will go into the same ever growing pile of mistakes not learned from.

Put every single calculation and/or check in a separate line, catching the value in a separate variable and check it under debugger/print it. Don't use the auto keyword for the types.

mmkay
Oct 21, 2010

Foxfire_ posted:

The main reason I think it's still around is that an optimizer being able to assume that things like "x+1 is always greater than x" is useful

Why would this differ between signed and unsigned integers?

mmkay
Oct 21, 2010

A small nitpick/hint, but you can automatically calculate the MAX_LIMITS based on the sizeof of the limits array (since it's statically allocated). That way it's more tightly coupled with it, which is what you want (you won't have to remember to change two places at once).

mmkay
Oct 21, 2010

ShoulderDaemon posted:

When I first started at my current employer, one of the simulators I became owner of was consistently formatted like this:
code:
if
    (foo) doStuff();
    else
{   doOtherStuff();
    doSomethingElse(); }
As near as I could tell, only one other person had ever touched the code, and they had left the company more than 5 years before I came onboard. Their choice of indentation was not even close to being the worst thing about it.

I deleted the entire codebase and rewrote the thing.

How did you find my university assignments?

mmkay
Oct 21, 2010

Over 10 years ago, and a different country, but I did have something like that for cryptography class. Each student would get a random algorithm and needed to create a program that would encrypt/decrypt a file with a password in ECB/CBC/OFB/CFB modes. Language and library choice was up to the student. I managed to get a very niche one (MARS) that the only library I found was with a bespoke Eclipse+Java installation.

Adbot
ADBOT LOVES YOU

mmkay
Oct 21, 2010

Sure? All the negatives about it were given at the lectures, but it was still a good starting point for all the clueless students for interfacing with the various libraries and designing the file format, since there were fewer parameters needed to pass along and you could debug any errors easier if you saw one block with an error instead of half the file.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply