Re: Is the code stateid_generation_after()in legal C?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Joakim Tjernlund wrote:

  static bool stateid_generation_after(stateid_t *a, stateid_t *b)
  {
          return (s32)a->si_generation - (s32)b->si_generation > 0;
  }
  
  overflow is undefined for signed integers and gcc uses that nowadays.
  Not sure if that can affect the above code?

I guess the intent there is to account for stateid wraparound. But it's not
clear to me this is doing the right thing. I think C specifies overflow
behavior for unsigned but not signed. So shouldn't it be something more like
this?

    (s32)(a->si_generation - b->si_generation) > 0

Either way, this probably deserves a comment.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux