axboe / liburing

Library providing helpers for the Linux kernel io_uring support
MIT License
2.72k stars 393 forks source link

`io_uring_check_version` documentation: should be `<=` instead of `>=` #1074

Closed ZhenbangYou closed 5 months ago

ZhenbangYou commented 5 months ago

The man page says, "The io_uring_check_version(3) function returns true if the liburing library loaded by the dynamic linker is greater-than or equal-to the major and minor numbers provided." However, according to the implementation (also shown below), it's NOT greater-than or equal-to, but less-than or equal-to.

bool io_uring_check_version(int major, int minor)
{
    return major > io_uring_major_version() ||
        (major == io_uring_major_version() &&
         minor >= io_uring_minor_version());
}

For example, I'm using liburing 2.6, and io_uring_check_version(2, 4) returns false. The same issue applies to IO_URING_CHECK_VERSION.

axboe commented 5 months ago

Huh, how odd is that. Might be better to update the documentation, as the compile time check is identical to this one. If we just flip them that has a higher risk of breaking.

axboe commented 5 months ago

Actually it looks worse than that as this is what I get:

major=2, minor=6
2.0 0
2.5 0
2.6 1
2.7 1
3.0 1
axboe commented 5 months ago

Pushed a fix, at least now it's consistent. Would be nice to swap them, but seems like a bad idea at this point.

ZhenbangYou commented 5 months ago

Thank you, Jens! Yeah it's a little strange that it returns false when version matches, but it's a safer way.

ZhenbangYou commented 5 months ago

A typo in the commit message of this commit: "If the majors are the same, only if the major is larger should we return true." The latter "major" should be "minor".

axboe commented 5 months ago

Oh well, nothing I can do about that now. But yeah, you are totally right.