I'm sure a lot of you know that I dropped the programming scene some years ago but I do occasionally poke my nose in and tinker around in the languages.

However, I'm at a loss. Mostly a logical one. Have you ever commented out whole segments of code? Here's an example. I'm thinking that if I un-comment the second, third & fourth highlighted segments, as well as other segments not in the pastebin, the code should work as I want it.

As for the first highlight, I'm not sure what that does...

What you are looking at is source (main.c) of a Canon XTi (400D) Firmware Exploit I downloaded a few days ago. The firmware works wonderfully. Except, ISO16-80 doesn't work. The camera recognizes the values and adjusts the exposure accordingly except the imaging censor shoots at the value plus another 100, so ISO16 becomes ISO116, while ISO125 stays 125.

At first I thought that camera was doing a cheap test of something like
Code:
If ISO < 100
ISO = ISO + 100
But clearly, that doesn't seem all that practical.

Back to the original question, any insight as to why someone would comment out portions of code? There are larger portions commented out, but they aren't relevant to my interests.

As far as screwing up my camera goes, I believe I'm safe. The exploit is placed on the CF card and I modified the CF card to be bootable so the camera will boot this exploit from the card rather than installing it onto itself.
comicIDIOT wrote:
Back to the original question, any insight as to why someone would comment out portions of code? There are larger portions commented out, but they aren't relevant to my interests.
Possibly because it was test code that doesn't work, or old code that has a replacement? If I comment out large swathes of code, I'll stick an explanation next to it, but as I generally use source control I'd rather just delete the code outright and document the removal when committing the changes.

That said, the code is pretty horrible. Ignoring the collection of magic numbers, shouldn't you either use if...else if or switch...case, rather than a large number of individual if statements, each ending in a goto? Confused
Basically what Benryves said. Commented-out code often (at least for me, and apparently Ben as well) represents previous working or nonworking code that was subsequently supplanted by "better" code of some sort.
benryves wrote:
comicIDIOT wrote:
Back to the original question, any insight as to why someone would comment out portions of code? There are larger portions commented out, but they aren't relevant to my interests.
Possibly because it was test code that doesn't work, or old code that has a replacement? If I comment out large swathes of code, I'll stick an explanation next to it, but as I generally use source control I'd rather just delete the code outright and document the removal when committing the changes.
Alright. I'm still going to uncomment and see what I get. If it doesn't work I shouldn't harm anything.

When I comment out code (in CSS) it's because I don't want to delete it just yet. it's also because I'm testing a second method and if that method is better, I'll delete what I commented out. So, I was at a loss.

Quote:
That said, the code is pretty horrible. Ignoring the collection of magic numbers, shouldn't you either use if...else if or switch...case, rather than a large number of individual if statements, each ending in a goto? Confused
I wouldn't know immediately if the code is horribly written. I just downloaded the source and am now looking at it. If I knew how to clean it up, I would try.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement