- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
int Destination = Project.Properties.Settings.Default.FRIST;
Admin
As long as the final iteration works, you will get an OK result. The previous 25 block do not matter, apparently.
Admin
is DST really meant as Daylight Savings Time, or just short for DeSTination (or DeStinaTion)?
Admin
I agree, particularly as the type is "int" rather than "bool".
Admin
That's what I thought. In fact I initially just read it that way, and didn't even think of Daylight Savings Time until Remy mentioned it. It's a very common abbreviation after all; but then I'm much more used to programming with hardware than to programming with time zones.
Admin
Well, that's good enough. The important bit is that you shouldn't use hardcoded values, right?
Admin
https://en.wikipedia.org/wiki/File:Project-triangle.svg
[phb]As you can clearly see, Cheap is the base of all. So provide this, and the other two will follow. [/phb]
Admin
Confused me a while until I realised "they all" referred to the bytes of the buffer. You can't often initialise a buffer to be of a certain length, because usually it is created with a certain length and then initialised with some contents.
Admin
I count a LOT of WTFs here:
1: The name of the variable that Destination is set equal to is not adequately named, and is confusing (see above comments). If it does stand for Daylight Saving Time, then dear god no.
2: Everything inside that big for loop could be condensed to:
for( int i = 0; i < 260; i++ )
{
}
3: WriteTenMemoryLocations is a thing. Why the heck 10?
4: Someone clearly knew how to properly initialize the list values to 0xFF, and then just commented that out even though it was more efficient than having the next list.
5: They couldn't decide whether to name the second list "data" or "values", suggesting someone really anal got in here and changed at least once and didn't fix it.
6: Pokémon catch statement. Gotta catch 'em all! Then return that we don't know what the error is...
7: Every run of the loop generates a new 260 byte List of which only 10 are referenced before it is destroyed.
8: Instead of using the first list of byte, a second list of byte is made and initialized to the same values as the first list.
So here's what I think happened: Someone just copied someone else's buffer writing method out of some other class, and modified it as little as possible because they didn't understand what they were doing and wanted to give off the illusion that they were a programmer. Someone else operating under the same illusion was asked to refactor the class at some point, so they changed the name of "data" to "values" and decided to initialize it with a CS101 loop. All of this code looks like it was designed to make a much more customized buffer and then later stripped down in order to make it just an initialization function.
Admin
I think I'm missing something here with point 7. The "out" List is created before the For loop and only get's added to if the count is less than 260, so the first time the loop goes through it goes into another For loop where it adds to "out" 260 - out.count times, bringing the count to 260. After the first pass of the main loop, out.count = 260 so it skips that step until the next time the whole function is called. I don't see anything in the For loop explicitly destroying the "out" list
sorry, I'm just trying to work on my code reading.
Admin
Except i is going to overflow in your version when it passes 255. Their version stopped just short of that.
Admin
When you get done submitting your thesis on writing bytes to memory, can you teach us all how to open a file and append a line to it?
Admin
"Why the heck 10?" Because as we all know, there are only 10 kinds of people in the world: those who understand binary and those who don't
Admin
In a very old language (1970s) There is a function called Fill. Feed it an address the number of bytes and the byte to fill the memory with and boom, it's done. Oop is so much better. Lol
Admin
>result &= WriteMemoryLocation( Destination, (byte)Block, (byte)i, 0xFF; Using a bitwise-and with booleans? Why the fuck did C never get &&= and ||= operators?
Admin
I'm guessing that the reason the
{0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
is that the compiler complained, and the dev couldn't figure out why.Last time I tried to do that type of thing (In Java, not C# though) we had to cast the 0xFF to a byte because the compiler complained. Or something. It's been a while.
Admin
A guess as to how to explain this:
Sometimes when debugging you want to fill uninitialized memory with a recognizable pattern so you can easily recognize it, and also to fish out latent bugs that wold be masked by filling with 0x00. So if you forget to null terminate a string it will still work if the memory is full of 0x00 but not if it's filled wit something else. Famous fills include 0xDEADBEEF or 0x0BADF00D.
This routine, in the past, may have used a pattern fill and then they decided to fill with a single value, so they changed the pattern but didn't simplify the routine (maybe they thought they'd change it back?)
Admin
Oh, oh dear god. I didn't even notice that. You're right, they need to change the start index into an int, or otherwise cast it in the WriteMemoryLocation function. Then again, their existing function must already do something to that extent. Most likely they are doing something like for (int i = (int)StartLocation, i < (int)StartLocation + 10, ++i) Still though, doesn't so much indicate that my method is flawed, just that I forgot about byte overflows. Jay: you're right. My code reading needs some work too apparently. It just does the checks over and over for no reason, it doesn't actually reconstruct the list every time. I feel like it tries to though.
Admin
When using a CRM system, customer service agents can quickly create incoming cases, track them with ease and escalate them when necessary. Calls can be automatically routed to the appropriate agent and updates are made in real-time, giving agents the ability to respond and exchange information quickly and efficiently. Contact our team of experts for any of your CRM needs www.acceinfo.com
Admin
When using a CRM system, customer service agents can quickly create incoming cases, track them with ease and escalate them when necessary. Calls can be automatically routed to the appropriate agent and updates are made in real-time, giving agents the ability to respond and exchange information quickly and efficiently. Contact our team of experts for any of your CRM needs www.acceinfo.com
Admin
I smiled at the "club penguin membership generator" spam: my kids used to be into Club Penguin but have since moved on, and my eldest daughter recently said she'd checked back in on it on a whim and found out that it's being shut down on March 29. Get those memberships while you can...