Repository: netty/netty
File: transport-classes-io_uring/src/main/java/io/netty/channel/uring/SubmissionQueue.java (Java)

Code before:

        if (logger.isTraceEnabled()) {
            if (opcode == Native.IORING_OP_WRITEV || opcode == Native.IORING_OP_READV) {
                logger.trace("add(ring {}): {}(fd={}, len={} ({} bytes), off={}, data={})",
                        ringFd, Native.opToStr(opcode), fd, len, Iov.sumSize(union2, len), union1, udata);
            } else {
                logger.trace("add(ring {}): {}(fd={}, len={}, off={}, data={})",
                        ringFd, Native.opToStr(opcode), fd, len, union1, udata);
            }
        }
    }

    @Override
    public String toString() {
        StringJoiner sb = new StringJoiner(", ", "SubmissionQueue [", "]");
        int pending = tail - head;
        for (int i = 0; i < pending; i++) {
            long sqe = submissionQueueArrayAddress + (head + i & ringMask) * SQE_SIZE;
            sb.add(Native.opToStr(PlatformDependent.getByte(sqe + SQE_OP_CODE_FIELD)) +
                    "(fd=" + PlatformDependent.getInt(sqe + SQE_FD_FIELD) + ')');
        }
        return sb.toString();
    }

    long addNop(byte flags, long udata) {
        // Mimic what liburing does. We want to use a count of 1:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L592
        return enqueueSqe0(Native.IORING_OP_NOP, flags, (short) 0, -1, 0, 0, 0, 0, udata,
                (short) 0, (short) 0, 0, 0);
    }

    long addTimeout(long nanoSeconds, long udata) {
        setTimeout(nanoSeconds);
        // Mimic what liburing does. We want to use a count of 1:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L599
        return enqueueSqe0(Native.IORING_OP_TIMEOUT, (byte) 0, (short) 0, -1, 1, timeoutMemoryAddress, 1,
                0, udata, (short) 0, (short) 0, 0, 0);
    }

    long addLinkTimeout(long nanoSeconds, long extraData) {
        setTimeout(nanoSeconds);
        // Mimic what liburing does:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L687
        return enqueueSqe0(Native.IORING_OP_LINK_TIMEOUT, (byte) 0, (short) 0, -1, 1, timeoutMemoryAddress, 1,
                0, extraData, (short) 0, (short) 0, 0, 0);
    }

    long addEventFdRead(int fd, long bufferAddress, int pos, int limit, long udata) {
        return enqueueSqe0(Native.IORING_OP_READ, (byte) 0, (short) 0, fd, 0, bufferAddress + pos, limit - pos,
                0, udata, (short) 0, (short) 0, 0, 0);
    }

Review comment (suggestion):
```suggestion
        // Mimic what liburing does:
```

Code after:

        if (logger.isTraceEnabled()) {
            if (opcode == Native.IORING_OP_WRITEV || opcode == Native.IORING_OP_READV) {
                logger.trace("add(ring {}): {}(fd={}, len={} ({} bytes), off={}, data={})",
                        ringFd, Native.opToStr(opcode), fd, len, Iov.sumSize(union2, len), union1, udata);
            } else {
                logger.trace("add(ring {}): {}(fd={}, len={}, off={}, data={})",
                        ringFd, Native.opToStr(opcode), fd, len, union1, udata);
            }
        }
    }

    @Override
    public String toString() {
        StringJoiner sb = new StringJoiner(", ", "SubmissionQueue [", "]");
        int pending = tail - head;
        for (int i = 0; i < pending; i++) {
            long sqe = submissionQueueArrayAddress + (head + i & ringMask) * SQE_SIZE;
            sb.add(Native.opToStr(PlatformDependent.getByte(sqe + SQE_OP_CODE_FIELD)) +
                    "(fd=" + PlatformDependent.getInt(sqe + SQE_FD_FIELD) + ')');
        }
        return sb.toString();
    }

    long addNop(byte flags, long udata) {
        // Mimic what liburing does:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L592
        return enqueueSqe0(Native.IORING_OP_NOP, flags, (short) 0, -1, 0, 0, 0, 0, udata,
                (short) 0, (short) 0, 0, 0);
    }

    long addTimeout(long nanoSeconds, long udata) {
        setTimeout(nanoSeconds);
        // Mimic what liburing does. We want to use a count of 1:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L599
        return enqueueSqe0(Native.IORING_OP_TIMEOUT, (byte) 0, (short) 0, -1, 1, timeoutMemoryAddress, 1,
                0, udata, (short) 0, (short) 0, 0, 0);
    }

    long addLinkTimeout(long nanoSeconds, long extraData) {
        setTimeout(nanoSeconds);
        // Mimic what liburing does:
        // https://github.com/axboe/liburing/blob/liburing-2.8/src/include/liburing.h#L687
        return enqueueSqe0(Native.IORING_OP_LINK_TIMEOUT, (byte) 0, (short) 0, -1, 1, timeoutMemoryAddress, 1,
                0, extraData, (short) 0, (short) 0, 0, 0);
    }

    long addEventFdRead(int fd, long bufferAddress, int pos, int limit, long udata) {
        return enqueueSqe0(Native.IORING_OP_READ, (byte) 0, (short) 0, fd, 0, bufferAddress + pos, limit - pos,
                0, udata, (short) 0, (short) 0, 0, 0);
    }