]> www.infradead.org Git - users/hch/misc.git/commitdiff
sunrpc: eliminate return pointer in svc_tcp_sendmsg()
authorJeff Layton <jlayton@kernel.org>
Mon, 11 Aug 2025 14:37:08 +0000 (10:37 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 21 Sep 2025 23:24:50 +0000 (19:24 -0400)
Return a positive value if something was sent, or a negative error code.
Eliminate the "err" variable in the only caller as well.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/svcsock.c

index 1afaeb45d6a37a5bf98ea2cda1ea36174ae03c85..c0d5a27ba674b05f76a506f147a9594f1f6b7936 100644 (file)
@@ -1224,7 +1224,7 @@ err_noclose:
  * that the pages backing @xdr are unchanging.
  */
 static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
-                          rpc_fraghdr marker, int *sentp)
+                          rpc_fraghdr marker)
 {
        struct msghdr msg = {
                .msg_flags      = MSG_SPLICE_PAGES,
@@ -1233,8 +1233,6 @@ static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
        void *buf;
        int ret;
 
-       *sentp = 0;
-
        /* The stream record marker is copied into a temporary page
         * fragment buffer so that it can be included in rq_bvec.
         */
@@ -1252,10 +1250,7 @@ static int svc_tcp_sendmsg(struct svc_sock *svsk, struct svc_rqst *rqstp,
                      1 + count, sizeof(marker) + rqstp->rq_res.len);
        ret = sock_sendmsg(svsk->sk_sock, &msg);
        page_frag_free(buf);
-       if (ret < 0)
-               return ret;
-       *sentp += ret;
-       return 0;
+       return ret;
 }
 
 /**
@@ -1274,7 +1269,7 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
        struct xdr_buf *xdr = &rqstp->rq_res;
        rpc_fraghdr marker = cpu_to_be32(RPC_LAST_STREAM_FRAGMENT |
                                         (u32)xdr->len);
-       int sent, err;
+       int sent;
 
        svc_tcp_release_ctxt(xprt, rqstp->rq_xprt_ctxt);
        rqstp->rq_xprt_ctxt = NULL;
@@ -1282,9 +1277,9 @@ static int svc_tcp_sendto(struct svc_rqst *rqstp)
        mutex_lock(&xprt->xpt_mutex);
        if (svc_xprt_is_dead(xprt))
                goto out_notconn;
-       err = svc_tcp_sendmsg(svsk, rqstp, marker, &sent);
-       trace_svcsock_tcp_send(xprt, err < 0 ? (long)err : sent);
-       if (err < 0 || sent != (xdr->len + sizeof(marker)))
+       sent = svc_tcp_sendmsg(svsk, rqstp, marker);
+       trace_svcsock_tcp_send(xprt, sent);
+       if (sent < 0 || sent != (xdr->len + sizeof(marker)))
                goto out_close;
        mutex_unlock(&xprt->xpt_mutex);
        return sent;
@@ -1295,8 +1290,8 @@ out_notconn:
 out_close:
        pr_notice("rpc-srv/tcp: %s: %s %d when sending %zu bytes - shutting down socket\n",
                  xprt->xpt_server->sv_name,
-                 (err < 0) ? "got error" : "sent",
-                 (err < 0) ? err : sent, xdr->len + sizeof(marker));
+                 (sent < 0) ? "got error" : "sent",
+                 sent, xdr->len + sizeof(marker));
        svc_xprt_deferred_close(xprt);
        mutex_unlock(&xprt->xpt_mutex);
        return -EAGAIN;