|
5.... because thats halarious
|
|
|
|
|
I also hope that RxData has an array length of (at least) 1028, though somehow I doubt it.
Faith is a fine invention
For gentlemen who see;
But microscopes are prudent
In an emergency!
-Emily Dickinson
|
|
|
|
|
David Kentley wrote: though somehow I doubt it
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker
My Blog - My Photos - ScrewTurn Wiki
|
|
|
|
|
<br />
PosBD = i; <br />
i = PosBD; <br />
I'd be suspicious that 'PosBD' doesn't hold the value of 1024 too well. But without seeing it's type, that's pure speculation.
Chris Meech
I am Canadian. [heard in a local bar]
|
|
|
|
|
Weeeell.. of course these two lines are to avoid that i has a different reference from PosBD
because you forgot to say that the type of i and PosBD is not int . the type of them is SuperInt which is a numeric Reference Type and for some reason we will possibly never understand it's very important that
a) a number must be stored as reference in this case
b) any changes will be made to i must be done to PosBD as well. just in case that 0 won't be 0 anymore someday..
|
|
|
|
|
PosBD = i;
i = PosBD;
The side effects of embedded C code are always amazing. Have you checked the types on these guys or revision history? I am willing to bet one is 16 bit in one file and 32 in another. I'd also wager if that is the case, there is an extern declaration somewhere
It is possible PosBD is overwriting i and the setting i to PosBD fixes it. A later file using the correct size of PosBD will not be affected! A lazy programmer did not check his/her types.
=========== Related experience showing why that might* make sense ============
I once worked on a system with lots of arrays which were global and 16 bit or 32 bit depending on the file they were used in. Needless to say lots of stuff got overwritten and until I realized what the problem was (and fixed it), another engineer did the following temporarily and was baffled:
<br />
extern int32 value[];<br />
extern int32 checks[]<br />
<br />
temp = value[x];<br />
checks[y] = variable;<br />
value[x] = temp;<br />
another file had this from the legacy system(syntax may be a bit off, its been a while)
<br />
int16 value[];<br />
int16 checks[];<br />
This fixed the problem, but he never knew why(found exact line w/ debugger). In reality, the checks array was overwriting the value array whenever the index was greater than half its size!
After I addressed the extern issues and fixed types, other parts of the system randomly started working or breaking (mostly working), depending on how they had been set up. By the end of the project, I was thanked for fixing things not in the spec... even though I had never touched them The client was satisfied.
-- modified at 13:07 Tuesday 31st July, 2007
|
|
|
|
|
Pualee wrote: The side effects of embedded C code are always amazing.
How true.
Pualee wrote: I am willing to bet one is 16 bit in one file and 32 in another.
Nope, both 32 bit, in the same file.
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker
My Blog - My Photos - ScrewTurn Wiki
|
|
|
|
|
I modified that post, check other files, is either variable externally declared with different types in other files?
Well... gave it my best effort
I guess my constant edits make it hard to understand my post, but its such an odd issue to explain, but when experienced, you'll never forget it
|
|
|
|
|
Agree with others, without knowing the types and context of this code, it's hard to say. Seems senseless at first, but in C that's a dangerous assumption.
: p
No other assembly programmers out there? The first thing I thought was the second assignment set the zero flag
: )
I'm inclined to think it's just a bit of bad coding... the giveaway is the fact that if there are no instances of 13-10-13-10 in the 1024 bytes the app will overflow on the 1021st iteration (unless the array allocated 1027 bytes, which would just be sloppy and still make me think it's crap code). I did think briefly about pointers, and pointers to pointers, but even that doesn't fit (no *s or &s).
It's just bad code, anyway you look at it.
What does PosBD stand for? Position of... Bad Data? BartDude? Maybe that would give some clue of what he was trying to do.
|
|
|
|
|
i was thinking POS stands for Point of Sale... in which case the code came from an inexperienced beginner programmer from India.... in which case its bad code. (please don't misunderstand me... i'm not saying that all programmers from india are bad programmers, i'm just saying the underpaid ones are )
|
|
|
|
|
As those of you who have read my other horrors may have guessed, I work for a bunch of loons with a penchant for Heath Robinson design. You might think I'm being a little bit harsh, but let me justify myself by explaining the current data flow I'm looking at:
1.) Data is exported from a "legacy" Dos application, and written to a fixed width format file
2.) Legacy Win32 app picks up the data, looks at it briefly, and then writes it to another, but different!, fixed width format file
3.) Legacy Win32 app picks up the file it has just written, and wraps it in EDI - the resulting file is called blah~date.edi (where blah is a meaningful name and date is the date in yymmdd format). Note the ~.
4.) Legacy Win32 app picks up the EDI file it just created, inserts a "header" and "footer" to the file (I understand this breaks EDI conventions), and saves the file, changing alll the ~'s to +'s in the file name to show that the header and footer insertion has happened.
5.) Legacy Win32 app transfers the file to an FTP server
***For the sake of your sanity, I'm going to ommit details of the hellish "Interchange Mechanism"***
6.) WinCE app contacts FTP server, finds work to download, and downloads and saves.
7.) Newly downloaded file is opened, header and footer are removed and file is saved replacing all +'s with ~'s.
8.) Edi file is now extracted to fixed width format as seen in 2.
9.) User performs work on file.
***Again, for your sanity, I'll ommit the actual work process, and we'll go straight to the completed and sending back stage***
10.) WinCE app picks up fixed width file and surrounds content with EDI tags and saves in the blah~date.edi format.
11.) WinCE app picks up newly created file, inserts a header and footer and saves the file replacing all the ~'s with +'s/
12.) WinCE app transfers file to FTP server
***More nastiness ensues - look away!***
13.) Legacy Win32 app contacts FTP server, finds file, downloads and svaes
14.) Newly downloaded file is opened, header and footer are removed and file is saved replacing all +'s with ~'s.
15.) EDI file is now extracted to a fixed width format (as seen in 2) and saved.
16.) Saved file is now opened, extraneous data removed and saved to another fixed width format as seen in 1.
17. File is presented to legacy Dos app.
Do you know what they said when I suggested this was a perfect (and actually, for once, legitimate) use for XML? "XML will never take off - EDI is where it's at!"!
"It was the day before today.... I remember it like it was yesterday."
-Moleman
|
|
|
|
|
You know that scene in Family Guy where a store clerk sees Meg Griffin, screams, pours gasoline over herself, lights herself on fire and then jumps out the window?
Yeah, I think I'd probably do that if I took one look at that app.
|
|
|
|
|
martin_hughes wrote: Do you know what they said when I suggested this was a perfect (and actually, for once, legitimate) use for XML? "XML will never take off - EDI is where it's at!"!
Awesome story, with the perfect punchline.
Faith is a fine invention
For gentlemen who see;
But microscopes are prudent
In an emergency!
-Emily Dickinson
|
|
|
|
|
You mean that's not the way you're meant to do it?
Dammit. Back to the drawing board...
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Was there any sort of cleanup operation after this, or did it just sit there?
And be grateful the EDI converters didn't create backups as well as the source, or maybe even some temp files for chunks too big to fit into conventional RAM because I'd imagine the system would be filled with useless file handles by now?
Need Another Seven Acronyms... Confused? You will be...
|
|
|
|
|
Put it this way; every 60 days (or thereabouts) a "purge" happens...
"It was the day before today.... I remember it like it was yesterday."
-Moleman
|
|
|
|
|
I actually covered my mouth in shock at that...
This story is going to give me nightmares.
|
|
|
|
|
What a story!
--------------------------------
txtSignature
|
|
|
|
|
ne0h wrote: What a story!
Uh huh, my thoughts exactly
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Isn't it fun to work with a bunch of ex-COBOL programmers ... at least I am assuming by your story that is what they used to do.
Phil
|
|
|
|
|
You actually almost lost me at one point – lol.
If I had not been in this business so long I might have been surprised, but the only thing that surprises me is that they gave you enough information to figure all that out.
Sorry I very tired right now – but that was very entertaining.
P.S. I am an old DOS guy so a time line for each step might have clarified why they did that to me (changing technology and all) – but I doubt it.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
I had a WTF moment while reading the documentation for a "database" system I'm evaluating (name changed to protect the guilty):
"
The precedence of arithmetical operators in SQL expressions differs from the SQL-92 standard. Fubar's SQL parses arithmetic expressions in strict left-to-right order, with no operator precedence.
"
I'm certainly glad I read that before trying to do any actual work with it. I wonder whether or not anyone's been bitten by it.
Certainly there's a work-around (lots of infuriating silly parentheses), but does anyone else find this unacceptable in a modern database system?
|
|
|
|
|
Yep, it's unacceptable. Having to kludge the precedence with parentheses will not only be mind-numbing extra work a but a maintenance headache. No excuse for this, since most earlier SQL standards specified normal operator precedence. I'd say it failed the evaluation because of non-standard precedence creating an error generator and maintenance killer.
|
|
|
|
|
We want that name... to stay away.
If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker
My Blog - My Photos - ScrewTurn Wiki
|
|
|
|
|
See Dave's post. I looked at that particular database some years ago, and never looked back at it.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|