0

I have this code that is warning me

Code :

int handle_operation(char *b) {
    char *buf = b;
    uint16_t opcode;
    memcpy(&opcode, buf, 2);
    buf = buf += 2;
}

Warning :

warning: operation on ‘buf’ may be undefined [-Wsequence-point]
   53 |     buf = buf++;

My goal is to increment the buffer's pointer by x each time I memcpy x bytes of it somewhere.

0xRyN
  • 852
  • 2
  • 13
  • 1
    The code shown does not match the code in the error message. Anyway, change the code to be `buf += 2;`. For more details read the duplicate post. – kaylum Jan 09 '22 at 02:32
  • @kaylum 3 am code hits hard... wow. Thanks – 0xRyN Jan 09 '22 at 02:34

0 Answers0