From 28549f676e040c96bfae575535dea7e0ecdf0f41 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2023 22:15:41 -0700 Subject: Change how constants are declared to play nice with godoc Switch to NAME Type = val instead of NAME = Type(val) --- lib/btrfs/Makefile | 2 +- lib/btrfs/btrfsitem/item_dir.go | 20 +++++----- lib/btrfs/btrfsitem/item_extent.go | 2 +- lib/btrfs/btrfsitem/item_fileextent.go | 4 +- lib/btrfs/btrfsitem/item_freespaceinfo.go | 2 +- lib/btrfs/btrfsitem/item_inode.go | 2 +- lib/btrfs/btrfsitem/item_root.go | 2 +- lib/btrfs/btrfsprim/itemtype.go | 64 +++++++++++++++---------------- lib/btrfs/btrfsprim/objid.go | 56 +++++++++++++-------------- lib/btrfs/btrfssum/csum.go | 2 +- lib/btrfs/btrfstree/types_node.go | 6 +-- lib/btrfs/btrfstree/types_superblock.go | 2 +- lib/btrfs/btrfsvol/blockgroupflags.go | 2 +- lib/containers/rbtree.go | 4 +- lib/fmtutil/bitfield.go | 2 +- 15 files changed, 86 insertions(+), 86 deletions(-) (limited to 'lib') diff --git a/lib/btrfs/Makefile b/lib/btrfs/Makefile index a1fe747..015c3e1 100644 --- a/lib/btrfs/Makefile +++ b/lib/btrfs/Makefile @@ -77,7 +77,7 @@ btrfsprim/itemtype.go: btrfsitem/items.txt $(MAKEFILE_LIST) echo 'import "fmt"'; \ echo 'type ItemType uint8'; \ echo 'const ('; \ - sed -E 's,(.*)=([^:]*)(:.*)? (trivial|complex) (.*),\1_KEY=ItemType(\2),' $< | uniq; \ + sed -E 's,(.*)=([^:]*)(:.*)? (trivial|complex) (.*),\1_KEY ItemType=\2,' $< | uniq; \ echo ')'; \ echo 'func (t ItemType) String() string {'; \ echo ' names := map[ItemType]string{'; \ diff --git a/lib/btrfs/btrfsitem/item_dir.go b/lib/btrfs/btrfsitem/item_dir.go index 0049072..0f263d5 100644 --- a/lib/btrfs/btrfsitem/item_dir.go +++ b/lib/btrfs/btrfsitem/item_dir.go @@ -84,17 +84,17 @@ func (o DirEntry) MarshalBinary() ([]byte, error) { type FileType uint8 const ( - FT_UNKNOWN = FileType(0) - FT_REG_FILE = FileType(1) - FT_DIR = FileType(2) - FT_CHRDEV = FileType(3) - FT_BLKDEV = FileType(4) - FT_FIFO = FileType(5) - FT_SOCK = FileType(6) - FT_SYMLINK = FileType(7) - FT_XATTR = FileType(8) + FT_UNKNOWN FileType = 0 + FT_REG_FILE FileType = 1 + FT_DIR FileType = 2 + FT_CHRDEV FileType = 3 + FT_BLKDEV FileType = 4 + FT_FIFO FileType = 5 + FT_SOCK FileType = 6 + FT_SYMLINK FileType = 7 + FT_XATTR FileType = 8 - FT_MAX = FileType(9) + FT_MAX FileType = 9 ) func (ft FileType) String() string { diff --git a/lib/btrfs/btrfsitem/item_extent.go b/lib/btrfs/btrfsitem/item_extent.go index 3789cfe..871ed90 100644 --- a/lib/btrfs/btrfsitem/item_extent.go +++ b/lib/btrfs/btrfsitem/item_extent.go @@ -111,7 +111,7 @@ type TreeBlockInfo struct { type ExtentFlags uint64 const ( - EXTENT_FLAG_DATA = ExtentFlags(1 << iota) + EXTENT_FLAG_DATA ExtentFlags = 1 << iota EXTENT_FLAG_TREE_BLOCK ) diff --git a/lib/btrfs/btrfsitem/item_fileextent.go b/lib/btrfs/btrfsitem/item_fileextent.go index 30a14ef..ce6c45c 100644 --- a/lib/btrfs/btrfsitem/item_fileextent.go +++ b/lib/btrfs/btrfsitem/item_fileextent.go @@ -101,7 +101,7 @@ func (o FileExtent) MarshalBinary() ([]byte, error) { type FileExtentType uint8 const ( - FILE_EXTENT_INLINE = FileExtentType(iota) + FILE_EXTENT_INLINE FileExtentType = iota FILE_EXTENT_REG FILE_EXTENT_PREALLOC ) @@ -133,7 +133,7 @@ func (fet FileExtentType) String() string { type CompressionType uint8 const ( - COMPRESS_NONE = CompressionType(iota) + COMPRESS_NONE CompressionType = iota COMPRESS_ZLIB COMPRESS_LZO COMPRESS_ZSTD diff --git a/lib/btrfs/btrfsitem/item_freespaceinfo.go b/lib/btrfs/btrfsitem/item_freespaceinfo.go index 0699367..9b886af 100644 --- a/lib/btrfs/btrfsitem/item_freespaceinfo.go +++ b/lib/btrfs/btrfsitem/item_freespaceinfo.go @@ -20,7 +20,7 @@ type FreeSpaceInfo struct { // trivial FREE_SPACE_INFO=198 type FreeSpaceFlags uint32 const ( - FREE_SPACE_USING_BITMAPS = FreeSpaceFlags(1 << iota) + FREE_SPACE_USING_BITMAPS FreeSpaceFlags = 1 << iota ) var freeSpaceFlagNames = []string{ diff --git a/lib/btrfs/btrfsitem/item_inode.go b/lib/btrfs/btrfsitem/item_inode.go index 69f8445..6951c76 100644 --- a/lib/btrfs/btrfsitem/item_inode.go +++ b/lib/btrfs/btrfsitem/item_inode.go @@ -36,7 +36,7 @@ type Inode struct { // trivial INODE_ITEM=1 type InodeFlags uint64 const ( - INODE_NODATASUM = InodeFlags(1 << iota) + INODE_NODATASUM InodeFlags = 1 << iota INODE_NODATACOW INODE_READONLY INODE_NOCOMPRESS diff --git a/lib/btrfs/btrfsitem/item_root.go b/lib/btrfs/btrfsitem/item_root.go index c0db900..d39bd70 100644 --- a/lib/btrfs/btrfsitem/item_root.go +++ b/lib/btrfs/btrfsitem/item_root.go @@ -48,7 +48,7 @@ type Root struct { // trivial ROOT_ITEM=132 type RootFlags uint64 const ( - ROOT_SUBVOL_RDONLY = RootFlags(1 << iota) + ROOT_SUBVOL_RDONLY RootFlags = 1 << iota ) var rootFlagNames = []string{ diff --git a/lib/btrfs/btrfsprim/itemtype.go b/lib/btrfs/btrfsprim/itemtype.go index 0b6baee..dba7ced 100644 --- a/lib/btrfs/btrfsprim/itemtype.go +++ b/lib/btrfs/btrfsprim/itemtype.go @@ -7,38 +7,38 @@ import "fmt" type ItemType uint8 const ( - BLOCK_GROUP_ITEM_KEY = ItemType(192) - CHUNK_ITEM_KEY = ItemType(228) - DEV_EXTENT_KEY = ItemType(204) - DEV_ITEM_KEY = ItemType(216) - DIR_INDEX_KEY = ItemType(96) - DIR_ITEM_KEY = ItemType(84) - EXTENT_CSUM_KEY = ItemType(128) - EXTENT_DATA_KEY = ItemType(108) - EXTENT_DATA_REF_KEY = ItemType(178) - EXTENT_ITEM_KEY = ItemType(168) - FREE_SPACE_BITMAP_KEY = ItemType(200) - FREE_SPACE_EXTENT_KEY = ItemType(199) - FREE_SPACE_INFO_KEY = ItemType(198) - INODE_ITEM_KEY = ItemType(1) - INODE_REF_KEY = ItemType(12) - METADATA_ITEM_KEY = ItemType(169) - ORPHAN_ITEM_KEY = ItemType(48) - PERSISTENT_ITEM_KEY = ItemType(249) - QGROUP_INFO_KEY = ItemType(242) - QGROUP_LIMIT_KEY = ItemType(244) - QGROUP_RELATION_KEY = ItemType(246) - QGROUP_STATUS_KEY = ItemType(240) - ROOT_BACKREF_KEY = ItemType(144) - ROOT_ITEM_KEY = ItemType(132) - ROOT_REF_KEY = ItemType(156) - SHARED_BLOCK_REF_KEY = ItemType(182) - SHARED_DATA_REF_KEY = ItemType(184) - TREE_BLOCK_REF_KEY = ItemType(176) - UNTYPED_KEY = ItemType(0) - UUID_RECEIVED_SUBVOL_KEY = ItemType(252) - UUID_SUBVOL_KEY = ItemType(251) - XATTR_ITEM_KEY = ItemType(24) + BLOCK_GROUP_ITEM_KEY ItemType = 192 + CHUNK_ITEM_KEY ItemType = 228 + DEV_EXTENT_KEY ItemType = 204 + DEV_ITEM_KEY ItemType = 216 + DIR_INDEX_KEY ItemType = 96 + DIR_ITEM_KEY ItemType = 84 + EXTENT_CSUM_KEY ItemType = 128 + EXTENT_DATA_KEY ItemType = 108 + EXTENT_DATA_REF_KEY ItemType = 178 + EXTENT_ITEM_KEY ItemType = 168 + FREE_SPACE_BITMAP_KEY ItemType = 200 + FREE_SPACE_EXTENT_KEY ItemType = 199 + FREE_SPACE_INFO_KEY ItemType = 198 + INODE_ITEM_KEY ItemType = 1 + INODE_REF_KEY ItemType = 12 + METADATA_ITEM_KEY ItemType = 169 + ORPHAN_ITEM_KEY ItemType = 48 + PERSISTENT_ITEM_KEY ItemType = 249 + QGROUP_INFO_KEY ItemType = 242 + QGROUP_LIMIT_KEY ItemType = 244 + QGROUP_RELATION_KEY ItemType = 246 + QGROUP_STATUS_KEY ItemType = 240 + ROOT_BACKREF_KEY ItemType = 144 + ROOT_ITEM_KEY ItemType = 132 + ROOT_REF_KEY ItemType = 156 + SHARED_BLOCK_REF_KEY ItemType = 182 + SHARED_DATA_REF_KEY ItemType = 184 + TREE_BLOCK_REF_KEY ItemType = 176 + UNTYPED_KEY ItemType = 0 + UUID_RECEIVED_SUBVOL_KEY ItemType = 252 + UUID_SUBVOL_KEY ItemType = 251 + XATTR_ITEM_KEY ItemType = 24 ) func (t ItemType) String() string { diff --git a/lib/btrfs/btrfsprim/objid.go b/lib/btrfs/btrfsprim/objid.go index 8ad290b..5896030 100644 --- a/lib/btrfs/btrfsprim/objid.go +++ b/lib/btrfs/btrfsprim/objid.go @@ -14,45 +14,45 @@ const maxUint64pp = 0x1_00000000_00000000 const ( // The IDs of the various trees - ROOT_TREE_OBJECTID = ObjID(1) // holds pointers to all of the tree roots - EXTENT_TREE_OBJECTID = ObjID(2) // stores information about which extents are in use, and reference counts - CHUNK_TREE_OBJECTID = ObjID(3) // chunk tree stores translations from logical -> physical block numbering - DEV_TREE_OBJECTID = ObjID(4) // stores info about which areas of a given device are in use; one per device - FS_TREE_OBJECTID = ObjID(5) // one per subvolume, storing files and directories - ROOT_TREE_DIR_OBJECTID = ObjID(6) // directory objectid inside the root tree - CSUM_TREE_OBJECTID = ObjID(7) // holds checksums of all the data extents - QUOTA_TREE_OBJECTID = ObjID(8) - UUID_TREE_OBJECTID = ObjID(9) // for storing items that use the UUID_*_KEY - FREE_SPACE_TREE_OBJECTID = ObjID(10) // tracks free space in block groups. - BLOCK_GROUP_TREE_OBJECTID = ObjID(11) // hold the block group items. + ROOT_TREE_OBJECTID ObjID = 1 // holds pointers to all of the tree roots + EXTENT_TREE_OBJECTID ObjID = 2 // stores information about which extents are in use, and reference counts + CHUNK_TREE_OBJECTID ObjID = 3 // chunk tree stores translations from logical -> physical block numbering + DEV_TREE_OBJECTID ObjID = 4 // stores info about which areas of a given device are in use; one per device + FS_TREE_OBJECTID ObjID = 5 // one per subvolume, storing files and directories + ROOT_TREE_DIR_OBJECTID ObjID = 6 // directory objectid inside the root tree + CSUM_TREE_OBJECTID ObjID = 7 // holds checksums of all the data extents + QUOTA_TREE_OBJECTID ObjID = 8 + UUID_TREE_OBJECTID ObjID = 9 // for storing items that use the UUID_*_KEY + FREE_SPACE_TREE_OBJECTID ObjID = 10 // tracks free space in block groups. + BLOCK_GROUP_TREE_OBJECTID ObjID = 11 // hold the block group items. // Objects in the DEV_TREE - DEV_STATS_OBJECTID = ObjID(0) // device stats in the device tree + DEV_STATS_OBJECTID ObjID = 0 // device stats in the device tree // ??? - BALANCE_OBJECTID = ObjID(maxUint64pp - 4) // for storing balance parameters in the root tree - ORPHAN_OBJECTID = ObjID(maxUint64pp - 5) // orphan objectid for tracking unlinked/truncated files - TREE_LOG_OBJECTID = ObjID(maxUint64pp - 6) // does write ahead logging to speed up fsyncs - TREE_LOG_FIXUP_OBJECTID = ObjID(maxUint64pp - 7) - TREE_RELOC_OBJECTID = ObjID(maxUint64pp - 8) // space balancing - DATA_RELOC_TREE_OBJECTID = ObjID(maxUint64pp - 9) - EXTENT_CSUM_OBJECTID = ObjID(maxUint64pp - 10) // extent checksums all have this objectid - FREE_SPACE_OBJECTID = ObjID(maxUint64pp - 11) // For storing free space cache - FREE_INO_OBJECTID = ObjID(maxUint64pp - 12) // stores the inode number for the free-ino cache - - MULTIPLE_OBJECTIDS = ObjID(maxUint64pp - 255) // dummy objectid represents multiple objectids + BALANCE_OBJECTID ObjID = maxUint64pp - 4 // for storing balance parameters in the root tree + ORPHAN_OBJECTID ObjID = maxUint64pp - 5 // orphan objectid for tracking unlinked/truncated files + TREE_LOG_OBJECTID ObjID = maxUint64pp - 6 // does write ahead logging to speed up fsyncs + TREE_LOG_FIXUP_OBJECTID ObjID = maxUint64pp - 7 + TREE_RELOC_OBJECTID ObjID = maxUint64pp - 8 // space balancing + DATA_RELOC_TREE_OBJECTID ObjID = maxUint64pp - 9 + EXTENT_CSUM_OBJECTID ObjID = maxUint64pp - 10 // extent checksums all have this objectid + FREE_SPACE_OBJECTID ObjID = maxUint64pp - 11 // For storing free space cache + FREE_INO_OBJECTID ObjID = maxUint64pp - 12 // stores the inode number for the free-ino cache + + MULTIPLE_OBJECTIDS ObjID = maxUint64pp - 255 // dummy objectid represents multiple objectids // All files have objectids in this range. - FIRST_FREE_OBJECTID = ObjID(256) - LAST_FREE_OBJECTID = ObjID(maxUint64pp - 256) + FIRST_FREE_OBJECTID ObjID = 256 + LAST_FREE_OBJECTID ObjID = maxUint64pp - 256 - FIRST_CHUNK_TREE_OBJECTID = ObjID(256) + FIRST_CHUNK_TREE_OBJECTID ObjID = 256 // Objects in the CHUNK_TREE - DEV_ITEMS_OBJECTID = ObjID(1) + DEV_ITEMS_OBJECTID ObjID = 1 // ??? - EMPTY_SUBVOL_DIR_OBJECTID = ObjID(2) + EMPTY_SUBVOL_DIR_OBJECTID ObjID = 2 ) func (id ObjID) Format(typ ItemType) string { diff --git a/lib/btrfs/btrfssum/csum.go b/lib/btrfs/btrfssum/csum.go index f436e2c..bce43f9 100644 --- a/lib/btrfs/btrfssum/csum.go +++ b/lib/btrfs/btrfssum/csum.go @@ -52,7 +52,7 @@ func (csum CSum) Format(f fmt.State, verb rune) { type CSumType uint16 const ( - TYPE_CRC32 = CSumType(iota) + TYPE_CRC32 CSumType = iota TYPE_XXHASH TYPE_SHA256 TYPE_BLAKE2 diff --git a/lib/btrfs/btrfstree/types_node.go b/lib/btrfs/btrfstree/types_node.go index fd4c939..0a89e05 100644 --- a/lib/btrfs/btrfstree/types_node.go +++ b/lib/btrfs/btrfstree/types_node.go @@ -58,7 +58,7 @@ var ( ) const ( - NodeWritten = NodeFlags(1 << iota) + NodeWritten NodeFlags = 1 << iota NodeReloc ) @@ -73,8 +73,8 @@ func (f NodeFlags) String() string { return fmtutil.BitfieldString(f, no type BackrefRev uint8 const ( - OldBackrefRev = BackrefRev(iota) - MixedBackrefRev = BackrefRev(iota) + OldBackrefRev BackrefRev = iota + MixedBackrefRev ) // Node: main ////////////////////////////////////////////////////////////////////////////////////// diff --git a/lib/btrfs/btrfstree/types_superblock.go b/lib/btrfs/btrfstree/types_superblock.go index 140d4a1..a9b1633 100644 --- a/lib/btrfs/btrfstree/types_superblock.go +++ b/lib/btrfs/btrfstree/types_superblock.go @@ -199,7 +199,7 @@ type RootBackup struct { type IncompatFlags uint64 const ( - FeatureIncompatMixedBackref = IncompatFlags(1 << iota) + FeatureIncompatMixedBackref IncompatFlags = 1 << iota FeatureIncompatDefaultSubvol FeatureIncompatMixedGroups FeatureIncompatCompressLZO diff --git a/lib/btrfs/btrfsvol/blockgroupflags.go b/lib/btrfs/btrfsvol/blockgroupflags.go index 0125664..37442de 100644 --- a/lib/btrfs/btrfsvol/blockgroupflags.go +++ b/lib/btrfs/btrfsvol/blockgroupflags.go @@ -11,7 +11,7 @@ import ( type BlockGroupFlags uint64 const ( - BLOCK_GROUP_DATA = BlockGroupFlags(1 << iota) + BLOCK_GROUP_DATA BlockGroupFlags = 1 << iota BLOCK_GROUP_SYSTEM BLOCK_GROUP_METADATA BLOCK_GROUP_RAID0 diff --git a/lib/containers/rbtree.go b/lib/containers/rbtree.go index 4125847..6182150 100644 --- a/lib/containers/rbtree.go +++ b/lib/containers/rbtree.go @@ -12,8 +12,8 @@ import ( type Color bool const ( - Black = Color(false) - Red = Color(true) + Black Color = false + Red Color = true ) type RBNode[T Ordered[T]] struct { diff --git a/lib/fmtutil/bitfield.go b/lib/fmtutil/bitfield.go index d46fee5..7f0b143 100644 --- a/lib/fmtutil/bitfield.go +++ b/lib/fmtutil/bitfield.go @@ -12,7 +12,7 @@ import ( type BitfieldFormat uint8 const ( - HexNone = BitfieldFormat(iota) + HexNone BitfieldFormat = iota HexLower HexUpper ) -- cgit v1.2.3-2-g168b