Closed Bug 1082963 Opened 10 years ago Closed 10 years ago

dist/include/ipc/nsGUIEventIPC.h:382:7: warning: variable 'isNull' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]

Categories

(Core :: DOM: Events, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla36

People

(Reporter: dholbert, Assigned: gyeh)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

New build warning:
{
dist/include/ipc/nsGUIEventIPC.h:382:7: warning: variable 'isNull' is used uninitialized whenever '&&' condition is false [-Wsometimes-uninitialized]
     bool isNull;
               ^
}

This is generated code, which looks like this:
  static bool Read(const Message* aMsg, void** aIter, paramType* aResult)
  {
    bool isNull;
    bool value;
    bool rv =
      ReadParam(aMsg, aIter,
                static_cast<mozilla::WidgetKeyboardEvent*>(aResult)) &&
      ReadParam(aMsg, aIter, &isNull) &&
      ReadParam(aMsg, aIter, &value);

    aResult->mEmbeddedCancelled = Nullable<bool>();
    if (!isNull) {
      aResult->mEmbeddedCancelled.SetValue(value);
    }

    return rv;
  }


The source for this code was added here, in bug 989198:
  https://hg.mozilla.org/mozilla-central/rev/186743fc6f6d#l4.23

Basically, we need to be checking whether "rv" is true, before we read "isNull". If rv is false, then we might have failed the first ReadParam call, which means we should definitely not be reading isNull.
Flags: needinfo?(gyeh)
Good catch, Daniel  ;)

Let me fix it today. Thanks.
Flags: needinfo?(gyeh)
Assignee: nobody → gyeh
Comment on attachment 8505264 [details] [diff] [review]
Patch 1(v1): Check rv before reading isNull

As Daniel described in bug description, we should check the return value of function ReadParam() before reading the resulted value.
Attachment #8505264 - Flags: review?(bugs)
Attachment #8505264 - Flags: feedback?(dholbert)
Comment on attachment 8505264 [details] [diff] [review]
Patch 1(v1): Check rv before reading isNull

Thanks for the quick turnaround! This seems reasonable to me, and I verified that this makes clang++ satisfied such that it no longer warns about this.
Attachment #8505264 - Flags: feedback?(dholbert) → feedback+
Attachment #8505264 - Flags: review?(bugs) → review+
https://hg.mozilla.org/mozilla-central/rev/a7c972407578
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla36
Bug 989198 was backed out. Please remember to include this fix when it re-lands.
You need to log in before you can comment on or make changes to this bug.