495 points · by beltex · 12y ago · 144 comments
http://opensource.apple.com/source/IOFWDVComponents/IOFWDVCo...
I see this:
#include <Carbon/Carbon.h>
//#include <Resources.h>
//#include <OSUtils.h>
//#include <Components.h>
#include "DeviceControlPriv.h"
#include "IsochronousDataHandler.h"
#include "DVVers.h"
#include <stdio.h>
#include <stdlib.h>
//#include <syslog.h>
// Debug messages
It's good to know that I'm not the only one who has commented out code in their shipping code:)
Still...
We never have.
Even if you tear it out, it's way more work to try to pull it all back out, line by line, and re-implement it than to comment it out and leave the actual debugging statements in #ifdef blocks that the pre-processor will pull out anyway.
You only make your source control more valuable by not commenting out code; since you can then search for its presence more easily. Good advice, all around.
Version control shows the evolution of design, if you are leaving in dead code you need to take a step back and think about the real solution.
I've never seen anyone dig through VCS history to gain a better understanding of code. And since presumably things change because the understanding evolves, I'm not even sure what the thought process is that would lead someone to do that.
You comment out code because your understanding might not be perfect, you might want the option to easily roll-back, or even have a reminder that a particular change was made. You'll remove it in the next revision or two.
So yeah. I've heard this before. It's complete and total nonsense IME.
One of my favourite interview questions:
A bug is found where given a specific series of user
interactions an error is raised. You search for this error
in code and you find that the error is raised in a very
old module which was written in a different style from
the main codebase by a developer who has long since left
the company. From a quick look around you see that this
code is very complex, and probably quite important. It's
obvious that it will take quite a bit of time to
understand what's going on simply by just reading the
code in the module where this error is raised.
Your job is to fix the bug. How do you approach this
problem?
At my company digging through VCS (and our ticketing system) in order to gain a better understanding of code is a very common.Edit:
I think if you're leaving commented out code for history's sake, you're Doing It Wrong. I disagree with the GP's idealism as much as you do, however. My beef with it is that if you're checking in commented code, you're obviously not reviewing your own diffs. It means you're likely to commit minor changes which were made for debugging purposes.
// comment this, just to get this stupid module out of my way.
//ensureNobodyDies();I'm actually going through the ancient CVS history of Mozilla Firefox in order to learn about a relatively poorly understood piece of code that's still in there to this day:
http://mikeconley.ca/blog/2014/07/07/docshell-in-a-nutshell-...
and
http://mikeconley.ca/blog/2014/08/10/docshell-in-a-nutshell-...
git bisect, git log, and git blame are all indispensable tools. To counter your anecdote, I use them all the time and see others do so.
There's really no reason to leave dead imports in a file.
Engineering wanted to move to git, so I would assume they are on the path to 100% git, annnnd.... probably already are at this point.
I asked Github if it was OK to upload the tens of gigabytes of source that the entirety of opensource.apple.com is and I got a "Sure, why not?" response. =)
I think the last time I updated these repos was around 10.7 or 10.8
[0]: https://github.com/Apple-FOSS-Mirror/
Edit: I was always wondering how I could manipulate git such that anyone could checkout my scripts and create identical git repos (same commit hashes and all) with a single command. I am somewhat hesitant to update the repos now because it would involve rewriting old commits since I haven't solved this problem yet.
Very easy to switch between OSX releases with the tags.
Some examples:
- The main kernel is open source (although not 100% identical to the version in OS X), but many kernel extensions are closed source, including quite basic stuff like disk image mounting.
- In one open source kernel extension I'm interested in, IOUSBFamily, functionality has been randomly disappearing in favor of empty .cpp files. Like several of the opensource releases, it doesn't actually compile...
- A version of CoreFoundation (C level API) is available, but not the full thing. The Objective-C runtime is available, but the core Objective-C libraries have never been.
- libxpc, which is rather low-level functionality added a few releases ago, was never open sourced; launchd is gone in this release, but before that it didn't compile, thanks to missing xpc headers.
- Bootloaders: BootX from PowerPC was open source, but the x86 EFI stuff was always closed source.
- libm is gone this release. cctools may be gone. Some libSystem libraries such as malloc and pthread were separated out in a previous release, but not open sourced; they're back now, though.
Few changes, but some interesting things pop out, like the addition of libmalloc and libpthread and the removal of memcached and securityd.
https://github.com/outbackdingo/launchd_xml https://github.com/rtyler/openlaunchd
Works on 10.1
http://web.archive.org/web/20120609100559/http://launchd.mac...
Unfortunate timing since it was finally getting a working port on FreeBSD.
Apparently the launchd code got rolled into xpc, which is closed source.
http://stackoverflow.com/questions/25505371/where-did-osxs-x...
Bug is not present in setxattr: http://opensource.apple.com/source/xnu/xnu-2782.1.97/bsd/vfs...
edit: Looks like you can: https://github.com/WebKit/webkit/tree/master/Source
This is where I was digging to find whether or not JavaScriptCore would still work with WKWebView. Spoiler: it won't.
It does encourage you to upstream your changes so you don't have to hire developers to keep up with upstream's improvements and deal with merge hell.
[Fingerprint: 92 D3 F3 46 0E BA A5 FE D5 5E C8 AE 19 59 82 57 85 FE AE 88 A5 9D F7 BE FC 47 89 38 5F BC 4A E9 (SHA-256)]
Like the following: http://osxdaily.com/2011/09/14/disable-the-internal-screen-o...
http://www.puredarwin.org/ looks abandoned, and OpenDarwin disappeared long ago - http://www.applematters.com/article/opendarwin-dies-a-lonely...
Ages? https://opensource.apple.com/ looks like it has for a while, except for the addition of 10.10 (I grab CFLite, libclosure, libdispatch, and objc4 whenever they're made available after a release).
+ unsigned int size = inCapacity * sizeof(dictEntry);
---------
rutina:~/git/bashcheck@master$ uname -a
Darwin rutina.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64
rutina:~/git/bashcheck@master$ ./bashcheck
Testing /bin/bash ...
Bash version 3.2.53(1)-release
Variable function parser pre/suffixed [__BASH_FUNC<..>(), apple], bugs not exploitable
Not vulnerable to CVE-2014-6271 (original shellshock)
Not vulnerable to CVE-2014-7169 (taviso bug)
Found non-exploitable CVE-2014-7186 (redir_stack bug)
Test for CVE-2014-7187 not reliable without address sanitizer
Found non-exploitable CVE-2014-6277 (lcamtuf bug #1)
Not vulnerable to CVE-2014-6278 (lcamtuf bug #2)
Or is this just the Darwin kernel code?
Are the aqua/user interface layer also included here?
Any CONTEXT related to this source code would be greatly appropriated.
I tried many years ago to use Darwin in the "haha I can run Mac OSX but not actually buy a Mac" sort of idea - it was an exercise in hard work (as I hadn't a clue what I was doing) and what I did managed to get to boot wasn't massively useful for "real" work (a CLI with no windowing layer) like development etc. or anything you do day to day.
Quite interesting nonetheless, but not massively useful.