tjko / nxgipd

nxgipd - a monitoring daemon for UTC Interlogix / GE Security / Caddx NetworX series alarm systems
GNU General Public License v2.0
39 stars 19 forks source link

Missing semicolon in process.c #5

Closed Dogora closed 9 years ago

Dogora commented 9 years ago

In process.c, you missed a semicolon on line 1095, and I think the lines using the macro SET_MSG_REPLY should be enclosed in braces.

The code is as follows:

  if (loc == 910) 
    SET_MSG_REPLY(reply,msg,0,0,"Factory Reset request sent (device=%d)",data[0])
  else 
    SET_MSG_REPLY(...)
  return;

It should be (in my opinion) this:

  if (loc == 910) {
    SET_MSG_REPLY(reply,msg,0,0,"Factory Reset request sent (device=%d)",data[0]);
  }
  else {
    SET_MSG_REPLY(...)
  }
  return;
 }
tjko commented 9 years ago

That macro expands to a block of code with braces around it (following is the result after same code snipped was passed through CPP):

    if (loc == 910)
      { logmsg(0,"Factory Reset request sent (device=%d)",data[0]); set_message_reply(reply,msg,0,"Factory Reset request sent (device=%d)",data[0]); }
    else
      { logmsg(0,"Program Data Command (#1) failed (device=%d,location=%d,type=%d,len=%d): %x", data[0],loc,datatype,datalen,msgin.msgnum); set_message_reply(reply,msg,3,"Program Data Command (#1) failed (device=%d,location=%d,type=%d,len=%d): %x", data[0],loc,datatype,datalen,msgin.msgnum); }

                                                ;
    return;
  }

But clearly some braces won't hurt to make it bit more readable...

Dogora commented 9 years ago

It seemed like it wasn't a problem because of the macro expansion. I only noticed it because Emacs got confused when I told it to re-indent.

tjko commented 9 years ago

It was really problem with emacs :) as compiler was perfectly happy with the results.... But I updated the code so it won't confuse editors...