Browse Source

Improved code readability

Tal Aloni 8 years ago
parent
commit
34ebbcd6b3

+ 4 - 5
ISCSI/ISCSI.PDU/LoginRequestPDU.cs

@@ -71,12 +71,11 @@ namespace ISCSI
             OpCodeSpecificHeader[1] = VersionMax;
             OpCodeSpecificHeader[2] = VersionMin;
 
-            Array.Copy(BigEndianConverter.GetBytes(ISID), 2, LUNOrOpCodeSpecific, 0, 6);
-            Array.Copy(BigEndianConverter.GetBytes(TSIH), 0, LUNOrOpCodeSpecific, 6, 2);
+            BigEndianWriter.WriteUInt64(LUNOrOpCodeSpecific, 0, ISID << 16 | TSIH);
 
-            Array.Copy(BigEndianConverter.GetBytes(CID), 0, OpCodeSpecific, 0, 2);
-            Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
+            BigEndianWriter.WriteUInt16(OpCodeSpecific, 0, CID);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, CmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
 
             Data = ASCIIEncoding.ASCII.GetBytes(LoginParametersText);
 

+ 5 - 6
ISCSI/ISCSI.PDU/LoginResponsePDU.cs

@@ -70,13 +70,12 @@ namespace ISCSI
 
             OpCodeSpecificHeader[1] = VersionMax;
             OpCodeSpecificHeader[2] = VersionActive;
-            Array.Copy(BigEndianConverter.GetBytes(ISID), 2, LUNOrOpCodeSpecific, 0, 6);
-            Array.Copy(BigEndianConverter.GetBytes(TSIH), 0, LUNOrOpCodeSpecific, 6, 2);
+            BigEndianWriter.WriteUInt64(LUNOrOpCodeSpecific, 0, ISID << 16 | TSIH);
 
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-            Array.Copy(BigEndianConverter.GetBytes((ushort)Status), 0, OpCodeSpecific, 16, 2);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt16(OpCodeSpecific, 16, (ushort)Status);
 
             Data = ASCIIEncoding.ASCII.GetBytes(LoginParametersText);
             

+ 3 - 3
ISCSI/ISCSI.PDU/LogoutRequestPDU.cs

@@ -37,9 +37,9 @@ namespace ISCSI
         {
             OpCodeSpecificHeader[0] = (byte)ReasonCode; // Final bit will be added by base.GetBytes()
 
-            Array.Copy(BigEndianConverter.GetBytes(CID), 0, OpCodeSpecific, 0, 2);
-            Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
+            BigEndianWriter.WriteUInt16(OpCodeSpecific, 0, CID);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, CmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
 
             return base.GetBytes();
         }

+ 5 - 6
ISCSI/ISCSI.PDU/LogoutResponsePDU.cs

@@ -42,12 +42,11 @@ namespace ISCSI
         {
             OpCodeSpecificHeader[1] = (byte)Response;
 
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-
-            Array.Copy(BigEndianConverter.GetBytes(TimeToWait), 0, OpCodeSpecific, 20, 2);
-            Array.Copy(BigEndianConverter.GetBytes(TimeToRetain), 0, OpCodeSpecific, 22, 2);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt16(OpCodeSpecific, 20, TimeToWait);
+            BigEndianWriter.WriteUInt16(OpCodeSpecific, 22, TimeToRetain);
 
             return base.GetBytes();
         }

+ 4 - 4
ISCSI/ISCSI.PDU/NOPInPDU.cs

@@ -41,10 +41,10 @@ namespace ISCSI
         {
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
 
             return base.GetBytes();
         }

+ 3 - 3
ISCSI/ISCSI.PDU/NOPOutPDU.cs

@@ -39,9 +39,9 @@ namespace ISCSI
         {
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, CmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
 
             return base.GetBytes();
         }

+ 7 - 7
ISCSI/ISCSI.PDU/ReadyToTransferPDU.cs

@@ -45,13 +45,13 @@ namespace ISCSI
         {
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-            Array.Copy(BigEndianConverter.GetBytes(R2TSN), 0, OpCodeSpecific, 16, 4);
-            Array.Copy(BigEndianConverter.GetBytes(BufferOffset), 0, OpCodeSpecific, 20, 4);
-            Array.Copy(BigEndianConverter.GetBytes(DesiredDataTransferLength), 0, OpCodeSpecific, 24, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, R2TSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 20, BufferOffset);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 24, DesiredDataTransferLength);
 
             return base.GetBytes();
         }

+ 4 - 4
ISCSI/ISCSI.PDU/RejectPDU.cs

@@ -39,10 +39,10 @@ namespace ISCSI
         {
             OpCodeSpecificHeader[1] = (byte)Reason;
 
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-            Array.Copy(BigEndianConverter.GetBytes(DataSN_R2TSN), 0, OpCodeSpecific, 16, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, DataSN_R2TSN);
 
             return base.GetBytes();
         }

+ 4 - 4
ISCSI/ISCSI.PDU/SCSICommandPDU.cs

@@ -57,10 +57,10 @@ namespace ISCSI
 
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(ExpectedDataTransferLength), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(CommandDescriptorBlock, 0, OpCodeSpecific, 12, CommandDescriptorBlock.Length);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, ExpectedDataTransferLength);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, CmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
+            ByteWriter.WriteBytes(OpCodeSpecific, 12, CommandDescriptorBlock);
             
             return base.GetBytes();
         }

+ 7 - 7
ISCSI/ISCSI.PDU/SCSIDataInPDU.cs

@@ -79,13 +79,13 @@ namespace ISCSI
 
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-            Array.Copy(BigEndianConverter.GetBytes(DataSN), 0, OpCodeSpecific, 16, 4);
-            Array.Copy(BigEndianConverter.GetBytes(BufferOffset), 0, OpCodeSpecific, 20, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ResidualCount), 0, OpCodeSpecific, 24, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, DataSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 20, BufferOffset);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 24, ResidualCount);
 
             return base.GetBytes();
         }

+ 4 - 4
ISCSI/ISCSI.PDU/SCSIDataOutPDU.cs

@@ -40,10 +40,10 @@ namespace ISCSI
         {
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(DataSN), 0, OpCodeSpecific, 16, 4);
-            Array.Copy(BigEndianConverter.GetBytes(BufferOffset), 0, OpCodeSpecific, 20, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, DataSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 20, BufferOffset);
 
             return base.GetBytes();
         }

+ 7 - 7
ISCSI/ISCSI.PDU/SCSIResponsePDU.cs

@@ -73,13 +73,13 @@ namespace ISCSI
             OpCodeSpecificHeader[1] = (byte)Response;
             OpCodeSpecificHeader[2] = (byte)Status;
 
-            Array.Copy(BigEndianConverter.GetBytes(SNACKTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpDataSN), 0, OpCodeSpecific, 16, 4);
-            Array.Copy(BigEndianConverter.GetBytes(BidirectionalReadResidualCount), 0, OpCodeSpecific, 20, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ResidualCount), 0, OpCodeSpecific, 24, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, SNACKTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 16, ExpDataSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 20, BidirectionalReadResidualCount);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 24, ResidualCount);
 
             return base.GetBytes();
         }

+ 4 - 4
ISCSI/ISCSI.PDU/TextRequestPDU.cs

@@ -48,10 +48,10 @@ namespace ISCSI
             }
 
             LUNOrOpCodeSpecific = LUN.GetBytes();
-            
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(CmdSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpStatSN), 0, OpCodeSpecific, 8, 4);
+
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, CmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpStatSN);
 
             Data = ASCIIEncoding.ASCII.GetBytes(Text);
 

+ 4 - 4
ISCSI/ISCSI.PDU/TextResponsePDU.cs

@@ -51,10 +51,10 @@ namespace ISCSI
 
             LUNOrOpCodeSpecific = LUN.GetBytes();
 
-            Array.Copy(BigEndianConverter.GetBytes(TargetTransferTag), 0, OpCodeSpecific, 0, 4);
-            Array.Copy(BigEndianConverter.GetBytes(StatSN), 0, OpCodeSpecific, 4, 4);
-            Array.Copy(BigEndianConverter.GetBytes(ExpCmdSN), 0, OpCodeSpecific, 8, 4);
-            Array.Copy(BigEndianConverter.GetBytes(MaxCmdSN), 0, OpCodeSpecific, 12, 4);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 0, TargetTransferTag);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 4, StatSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 8, ExpCmdSN);
+            BigEndianWriter.WriteUInt32(OpCodeSpecific, 12, MaxCmdSN);
 
             Data = ASCIIEncoding.ASCII.GetBytes(Text);
 

+ 1 - 1
ISCSI/SCSI/SCSICommandDescriptorBlock/InquiryCommandDescriptorBlock.cs

@@ -39,7 +39,7 @@ namespace SCSI
                 buffer[1] |= 0x01;
             }
             buffer[2] = (byte)PageCode;
-            Array.Copy(BigEndianConverter.GetBytes(AllocationLength), 0, buffer, 3, 2);
+            BigEndianWriter.WriteUInt16(buffer, 3, AllocationLength);
             buffer[5] = Control;
             return buffer;
         }

+ 2 - 2
ISCSI/SCSI/SCSICommandDescriptorBlock/SCSICommandDescriptorBlock10.cs

@@ -39,9 +39,9 @@ namespace SCSI
             buffer[0] = (byte)OpCode;
             buffer[1] |= (byte)(MiscellaneousCDBInformationHeader << 5);
             buffer[1] |= (byte)((byte)ServiceAction & 0x1F);
-            Array.Copy(BigEndianConverter.GetBytes(LogicalBlockAddress), 0, buffer, 2, 4);
+            BigEndianWriter.WriteUInt32(buffer, 2, LogicalBlockAddress);
             buffer[6] = MiscellaneousCDBinformation;
-            Array.Copy(BigEndianConverter.GetBytes((ushort)TransferLength), 0, buffer, 7, 2);
+            BigEndianWriter.WriteUInt16(buffer, 7, (ushort)TransferLength);
             buffer[9] = Control;
             return buffer;
         }

+ 2 - 2
ISCSI/SCSI/SCSICommandDescriptorBlock/SCSICommandDescriptorBlock12.cs

@@ -39,8 +39,8 @@ namespace SCSI
             buffer[0] = (byte)OpCode;
             buffer[1] |= (byte)(MiscellaneousCDBInformationHeader << 5);
             buffer[1] |= (byte)((byte)ServiceAction & 0x1F);
-            Array.Copy(BigEndianConverter.GetBytes(LogicalBlockAddress), 0, buffer, 2, 4);
-            Array.Copy(BigEndianConverter.GetBytes(TransferLength), 0, buffer, 6, 4);
+            BigEndianWriter.WriteUInt32(buffer, 2, LogicalBlockAddress);
+            BigEndianWriter.WriteUInt32(buffer, 6, TransferLength);
             buffer[10] = MiscellaneousCDBinformation;
             buffer[11] = Control;
             return buffer;

+ 5 - 5
ISCSI/SCSI/SCSIReturnParameters/ModePages/CachingParametersPage.cs

@@ -106,10 +106,10 @@ namespace SCSI
             buffer[3] = (byte)((DemandReadRetentionPriority & 0x0F) << 4);
             buffer[3] = (byte)(WriteRetentionPriority & 0x0F);
 
-            Array.Copy(BigEndianConverter.GetBytes(DisablePrefetchTransferLength), 0, buffer, 4, 2);
-            Array.Copy(BigEndianConverter.GetBytes(MinimumPrefetch), 0, buffer, 6, 2);
-            Array.Copy(BigEndianConverter.GetBytes(MaximumPrefetch), 0, buffer, 8, 2);
-            Array.Copy(BigEndianConverter.GetBytes(MaximumPrefetchCeiling), 0, buffer, 10, 2);
+            BigEndianWriter.WriteUInt16(buffer, 4, DisablePrefetchTransferLength);
+            BigEndianWriter.WriteUInt16(buffer, 6, MinimumPrefetch);
+            BigEndianWriter.WriteUInt16(buffer, 8, MaximumPrefetch);
+            BigEndianWriter.WriteUInt16(buffer, 10, MaximumPrefetchCeiling);
 
             if (FSW)
             {
@@ -129,7 +129,7 @@ namespace SCSI
             }
 
             buffer[13] = NumberOfCacheSegments;
-            Array.Copy(BigEndianConverter.GetBytes(CacheSegmentSize), 0, buffer, 14, 2);
+            BigEndianWriter.WriteUInt16(buffer, 14, CacheSegmentSize);
 
             return buffer;
         }

+ 4 - 4
ISCSI/SCSI/SCSIReturnParameters/StandardInquiryData.cs

@@ -194,10 +194,10 @@ namespace SCSI
                 buffer[7] |= 0x01;
             }
 
-            Array.Copy(ASCIIEncoding.ASCII.GetBytes(VendorIdentification), 0, buffer, 8, Math.Min(VendorIdentification.Length, 8));
-            Array.Copy(ASCIIEncoding.ASCII.GetBytes(ProductIdentification), 0, buffer, 16, Math.Min(ProductIdentification.Length, 16));
-            Array.Copy(ASCIIEncoding.ASCII.GetBytes(ProductRevisionLevel), 0, buffer, 32, 4);
-            Array.Copy(BigEndianConverter.GetBytes(DriveSerialNumber), 0, buffer, 36, 8);
+            ByteWriter.WriteAnsiString(buffer, 8, VendorIdentification, 8);
+            ByteWriter.WriteAnsiString(buffer, 16, ProductIdentification, 16);
+            ByteWriter.WriteAnsiString(buffer, 32, ProductRevisionLevel, 4);
+            BigEndianWriter.WriteUInt64(buffer, 36, DriveSerialNumber);
 
 
             buffer[56] |= (byte)((Clocking & 0x03) << 2);

+ 1 - 1
ISCSI/SCSI/SCSIReturnParameters/VPDPages/DeviceIdentificationVPDPage.cs

@@ -51,7 +51,7 @@ namespace SCSI
             buffer[0] |= (byte)(PeripheralQualifier << 5);
             buffer[0] |= (byte)(PeripheralQualifier & 0x1F);
             buffer[1] = (byte)PageCode;
-            Array.Copy(BigEndianConverter.GetBytes(PageLength), 0, buffer, 2, 2);
+            BigEndianWriter.WriteUInt16(buffer, 2, PageLength);
 
             int offset = 4;
             foreach (IdentificationDescriptor descriptor in IdentificationDescriptorList)

+ 2 - 2
ISCSI/SCSITarget/VirtualSCSITarget.cs

@@ -481,8 +481,8 @@ namespace SCSI
         {
             byte[] senseDataBytes = senseData.GetBytes();
             byte[] result = new byte[senseDataBytes.Length + 2];
-            Array.Copy(BigEndianConverter.GetBytes((ushort)senseDataBytes.Length), 0, result, 0, 2);
-            Array.Copy(senseDataBytes, 0, result, 2, senseDataBytes.Length);
+            BigEndianWriter.WriteUInt16(result, 0, (ushort)senseDataBytes.Length);
+            ByteWriter.WriteBytes(result, 2, senseDataBytes);
             return result;
         }
     }