Given the variance in the depth of drive of a nail, how stringent are codes for length of nail when framing?
Few people use 2-3/8" nails for framing with lumber. They're commonly used (in ring-shank form) for subfloors, sheathing boxes (think fireplace surrounds and soffits), and other light-duty uses. 

Just as that size isn't truly an 8d (eight-penny) nail, 3" framing nails aren't truly 16d. They're thinner and shorter than a traditional 16d sinker. For that reason, most framers do their toenailing with 3" gun nails, and most only use 3 (2 from one side, one from the other). No inspector I've ever encountered raised this as an issue, and my extensive experience tells me that it's plenty strong.

You asked about codes, and I've answered in practical terms (the spirit of the law, so to speak). Codes only mean what inspectors and quality-conscious carpenters interpret them to mean. Perhaps others can speak more to "the letter of the law".