Bad style…

This is a peculiar piece of code from the MiniSpy sample of the IFS kit…


FLT_POSTOP_CALLBACK_STATUS
SpyPostOperationCallback (
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
)
{
PFLT_TAG_DATA_BUFFER tagData;

....

//
// Log reparse tag information if specified.
//

if (tagData = Data->TagData) {

....

It’s not a bug, but it would be much clearer to rewrite it as…


if (NULL != Data->TagData) {
tagData = Data->TagData;
....

Advertisements
This entry was posted in Programming. Bookmark the permalink.

2 Responses to Bad style…

  1. Rich says:

    Does tagData get initialized to NULL somewhere in the first ellipses or do you want to switch those two lines? Or is it only used inside the if clause…

    On another note, though I’m ever one to come to things late in the game, you’re right the mars volta is really good.

  2. Jeremy says:

    tagData doesn’t get initialized until the if() clause, and it’s not used outside that same clause after that.

    Some of the samples for that part of the DDK are pretty old so I think things like that are leftovers from someone having to write “optimized” code better than the compilers could at that point.

    And yeah, great band.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s