Skip to content

Commit cb6fb9f

Browse files
MagicalTuxclaude
andcommitted
fix: handle remaining unchecked binary.Write errors in writeInode
Add explicit _ = prefix to all binary.Write calls in writeInode function since they write to bytes.Buffer which never fails. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 871e253 commit cb6fb9f

1 file changed

Lines changed: 30 additions & 30 deletions

File tree

writer.go

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -496,60 +496,60 @@ func (w *Writer) writeInode(node *writerInode, inodeMeta *streamingMetaWriter) e
496496
buf := &bytes.Buffer{}
497497
order := binary.LittleEndian
498498

499-
// Common header
500-
binary.Write(buf, order, node.fileType)
501-
binary.Write(buf, order, uint16(node.mode&0777))
502-
binary.Write(buf, order, uint16(w.idTable[node.uid]))
503-
binary.Write(buf, order, uint16(w.idTable[node.gid]))
504-
binary.Write(buf, order, int32(node.modTime))
505-
binary.Write(buf, order, node.ino)
499+
// Common header (bytes.Buffer never fails, explicitly ignore errors)
500+
_ = binary.Write(buf, order, node.fileType)
501+
_ = binary.Write(buf, order, uint16(node.mode&0777))
502+
_ = binary.Write(buf, order, uint16(w.idTable[node.uid]))
503+
_ = binary.Write(buf, order, uint16(w.idTable[node.gid]))
504+
_ = binary.Write(buf, order, int32(node.modTime))
505+
_ = binary.Write(buf, order, node.ino)
506506

507507
switch node.fileType {
508508
case DirType:
509509
// For directories, we know the dir position because we wrote entries first
510-
binary.Write(buf, order, node.dirBlockIdx) // Will be converted to physical later
511-
binary.Write(buf, order, node.nlink)
512-
binary.Write(buf, order, uint16(node.size))
513-
binary.Write(buf, order, node.dirOffset)
510+
_ = binary.Write(buf, order, node.dirBlockIdx) // Will be converted to physical later
511+
_ = binary.Write(buf, order, node.nlink)
512+
_ = binary.Write(buf, order, uint16(node.size))
513+
_ = binary.Write(buf, order, node.dirOffset)
514514
parentIno := uint32(1)
515515
if node.parent != nil {
516516
parentIno = node.parent.ino
517517
}
518-
binary.Write(buf, order, parentIno)
518+
_ = binary.Write(buf, order, parentIno)
519519

520520
case XDirType:
521-
binary.Write(buf, order, node.nlink)
522-
binary.Write(buf, order, uint32(node.size))
523-
binary.Write(buf, order, node.dirBlockIdx) // Will be converted to physical later
521+
_ = binary.Write(buf, order, node.nlink)
522+
_ = binary.Write(buf, order, uint32(node.size))
523+
_ = binary.Write(buf, order, node.dirBlockIdx) // Will be converted to physical later
524524
parentIno := uint32(1)
525525
if node.parent != nil {
526526
parentIno = node.parent.ino
527527
}
528-
binary.Write(buf, order, parentIno)
529-
binary.Write(buf, order, uint16(0)) // index count
530-
binary.Write(buf, order, node.dirOffset) // offset
531-
binary.Write(buf, order, uint32(0xFFFFFFFF)) // xattr index
528+
_ = binary.Write(buf, order, parentIno)
529+
_ = binary.Write(buf, order, uint16(0)) // index count
530+
_ = binary.Write(buf, order, node.dirOffset) // offset
531+
_ = binary.Write(buf, order, uint32(0xFFFFFFFF)) // xattr index
532532

533533
case FileType:
534-
binary.Write(buf, order, uint32(node.startBlock))
535-
binary.Write(buf, order, uint32(0xFFFFFFFF)) // fragment block
536-
binary.Write(buf, order, uint32(0)) // fragment offset
537-
binary.Write(buf, order, uint32(node.size))
534+
_ = binary.Write(buf, order, uint32(node.startBlock))
535+
_ = binary.Write(buf, order, uint32(0xFFFFFFFF)) // fragment block
536+
_ = binary.Write(buf, order, uint32(0)) // fragment offset
537+
_ = binary.Write(buf, order, uint32(node.size))
538538
for _, blockSize := range node.dataBlocks {
539-
binary.Write(buf, order, blockSize)
539+
_ = binary.Write(buf, order, blockSize)
540540
}
541541

542542
case SymlinkType:
543-
binary.Write(buf, order, node.nlink)
544-
binary.Write(buf, order, uint32(len(node.symTarget)))
545-
buf.Write([]byte(node.symTarget))
543+
_ = binary.Write(buf, order, node.nlink)
544+
_ = binary.Write(buf, order, uint32(len(node.symTarget)))
545+
_, _ = buf.Write([]byte(node.symTarget))
546546

547547
case CharDevType, BlockDevType:
548-
binary.Write(buf, order, node.nlink)
549-
binary.Write(buf, order, uint32(0))
548+
_ = binary.Write(buf, order, node.nlink)
549+
_ = binary.Write(buf, order, uint32(0))
550550

551551
case FifoType, SocketType:
552-
binary.Write(buf, order, node.nlink)
552+
_ = binary.Write(buf, order, node.nlink)
553553
}
554554

555555
_, err := inodeMeta.Write(buf.Bytes())

0 commit comments

Comments
 (0)