Uploaded image for project: 'WiredTiger'
  1. WiredTiger
  2. WT-1292

CID 1248178: Wrong operator used

    • Type: Icon: Task Task
    • Resolution: Done
    • WT2.4.1
    • Affects Version/s: None
    • Component/s: None

      Don, Coverity is complaining about this code, would you please take a look?

      *** CID 1248178:  Wrong operator used  (CONSTANT_EXPRESSION_RESULT)
      /src/cursor/cur_json.c: 900 in __wt_json_strncpy()
      894                                     /* RFC 3629 */
      895                                     if (hi >= 0x8) {
      896                                             /* 3 bytes total */
      897                                             /* byte 0: 1110HHHH */
      898                                             /* byte 1: 10HHHHLL */
      899                                             /* byte 2: 10LLLLLL */
      >>>     CID 1248178:  Wrong operator used  (CONSTANT_EXPRESSION_RESULT)
      >>>     "(hi << 4) & 0xf" is always 0 regardless of the values of its operands. This occurs as the bitwise second operand of '|'. Did you intend to use right-shift ('>>') in "hi << 4"?
      900                                             *dst++ = (char)(0xe0 |
      901                                                 ((hi << 4) & 0x0f));
      902                                             *dst++ = (char)(0x80 |
      903                                                 ((hi << 2) & 0x3c) |
      904                                                 ((lo >> 6) & 0x03));
      905                                             *dst++ = (char)(0x80 | (lo & 0x3f));
      

            Assignee:
            donald.anderson@mongodb.com Donald Anderson
            Reporter:
            keith.bostic@mongodb.com Keith Bostic (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: