fix possible wrong cast to 32-bit unsigned
authorPeter Lieven <pl@kamp.de>
Sat, 15 Mar 2014 14:58:08 +0000 (15:58 +0100)
committerPeter Lieven <pl@kamp.de>
Sun, 16 Mar 2014 19:07:52 +0000 (20:07 +0100)
when calculation the max_offset the (unsigned) leads to a cast
to a 32-bit unsigned integer depending on the platform. as a result
we update the max_offset everytime when it grows beyond 2^32.
this leads to a wrong return max_offset value if the callbacks
are received out of order.

Signed-off-by: Peter Lieven <pl@kamp.de>
lib/libnfs.c

index 937cb9d2ea59dde379cd57b3f63fca6f65f012fe..8506795a10fafd7922abf56a2907cb8ba090fed4 100644 (file)
@@ -1598,7 +1598,7 @@ static void nfs_pread_mcb(struct rpc_context *rpc, int status, void *command_dat
                        if (res->READ3res_u.resok.count > 0) {
                                if (res->READ3res_u.resok.count <= mdata->count) {
                                        memcpy(&data->buffer[mdata->offset - data->start_offset], res->READ3res_u.resok.data.data_val, res->READ3res_u.resok.count);
-                                       if ((unsigned)data->max_offset < mdata->offset + res->READ3res_u.resok.count) {
+                                       if (data->max_offset < mdata->offset + res->READ3res_u.resok.count) {
                                                data->max_offset = mdata->offset + res->READ3res_u.resok.count;
                                        }
                                } else {
@@ -1807,7 +1807,7 @@ static void nfs_pwrite_mcb(struct rpc_context *rpc, int status, void *command_da
                        data->error = 1;
                } else  {
                        if (res->WRITE3res_u.resok.count > 0) {
-                               if ((unsigned)data->max_offset < mdata->offset + res->WRITE3res_u.resok.count) {
+                               if (data->max_offset < mdata->offset + res->WRITE3res_u.resok.count) {
                                        data->max_offset = mdata->offset + res->WRITE3res_u.resok.count;
                                }
                        }