We only need to spend CPU computing a new error string IFF there was an error
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 12 Mar 2014 12:54:38 +0000 (05:54 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 12 Mar 2014 12:54:38 +0000 (05:54 -0700)
when unmarshalling the reply.

lib/libnfs-zdr.c

index 7c971e003eaf104916c20eb8036fd5e6756ad8ab..c32f661fc86cc8170940673e4b10c3d4deebce2d 100644 (file)
@@ -456,16 +456,18 @@ static bool_t libnfs_rpc_msg(struct rpc_context *rpc, ZDR *zdrs, struct rpc_msg
        switch (msg->direction) {
        case CALL:
                ret = libnfs_rpc_call_body(rpc, zdrs, &msg->body.cbody);
-               rpc_set_error(rpc, "libnfs_rpc_msg failed to encode CALL, "
-                       "ret=%d: %s", ret, rpc_get_error(rpc));
+               if (!ret) { 
+                       rpc_set_error(rpc, "libnfs_rpc_msg failed to encode "
+                               "CALL, ret=%d: %s", ret, rpc_get_error(rpc));
+               }
                return ret;
-               break;
        case REPLY:
                ret = libnfs_rpc_reply_body(rpc, zdrs, &msg->body.rbody);
-               rpc_set_error(rpc, "libnfs_rpc_msg failed to decode REPLY, "
-                       "ret=%d: %s", ret, rpc_get_error(rpc));
+               if (!ret) { 
+                       rpc_set_error(rpc, "libnfs_rpc_msg failed to decode "
+                               "REPLY, ret=%d: %s", ret, rpc_get_error(rpc));
+               }
                return ret;
-               break;
        default:
                rpc_set_error(rpc, "libnfs_rpc_msg failed to decode. "
                        "Neither CALL not REPLY");