[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH 3/3] volume_id: uuid_format small code shrink
From: Sven-Göran_Bergh <svengbergh-busybox () yahoo ! com>
Date: 2012-11-21 15:08:18
Message-ID: 1353510498.68426.YahooMailNeo () web121806 ! mail ! ne1 ! yahoo ! com
[Download RAW message or body]
This patch depends on patch #2 in this set.
When #2 is applied it is possible to get rid
of a few additional bytes.
volume_id: uuid_format small code shrink
function old new delta
volume_id_probe_luks 90 93 +3
volume_id_set_uuid 295 296 +1
volume_id_probe_vfat 888 885 -3
volume_id_probe_exfat 254 251 -3
static.CSWTCH 16 8 -8
.rodata 148893 148877 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/4 up/down: 4/-30) Total: -26 bytes
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
---
util-linux/volume_id/util.c | 17 +----------------
util-linux/volume_id/volume_id_internal.h | 10 +++++-----
2 files changed, 6 insertions(+), 21 deletions(-)
Patch attached.
["3-volume_id-small-code-shrink.patch" (application/octet-stream)]
commit 8cb83d908d81981b736a11ad0315d58fc32a2b9f
Author: Sven-Göran Bergh <sgb@systemasis.org>
Date: Tue Nov 20 20:05:45 2012 +0100
volume_id: uuid_format small code shrink
function old new delta
volume_id_probe_luks 90 93 +3
volume_id_set_uuid 295 296 +1
volume_id_probe_vfat 888 885 -3
volume_id_probe_exfat 254 251 -3
static.CSWTCH 16 8 -8
.rodata 148893 148877 -16
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 2/4 up/down: 4/-30) Total: -26 bytes
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org>
---
util-linux/volume_id/util.c | 17 +----------------
util-linux/volume_id/volume_id_internal.h | 10 +++++-----
2 files changed, 6 insertions(+), 21 deletions(-)
diff --git a/util-linux/volume_id/util.c b/util-linux/volume_id/util.c
index 11ee0d5..2602a71 100644
--- a/util-linux/volume_id/util.c
+++ b/util-linux/volume_id/util.c
@@ -135,23 +135,8 @@ void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enu
void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format)
{
unsigned i;
- unsigned count = 0;
+ unsigned count = format == UUID_DCE_STRING ? VOLUME_ID_UUID_SIZE : 0x04 << format;
- switch (format) {
- case UUID_DOS:
- count = 4;
- break;
- case UUID_NTFS:
- count = 8;
- break;
- case UUID_DCE:
- count = 16;
- break;
- case UUID_DCE_STRING:
- /* 36 is ok, id->uuid has one extra byte for NUL */
- count = VOLUME_ID_UUID_SIZE;
- break;
- }
// memcpy(id->uuid_raw, buf, count);
// id->uuid_raw_len = count;
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
index dd62df3..7677a01 100644
--- a/util-linux/volume_id/volume_id_internal.h
+++ b/util-linux/volume_id/volume_id_internal.h
@@ -136,11 +136,11 @@ void FAST_FUNC free_volume_id(struct volume_id *id);
#define cpu_to_be32(x) (x)
#endif
-enum uuid_format {
- UUID_DCE_STRING,
- UUID_DCE,
- UUID_DOS,
- UUID_NTFS,
+enum uuid_format { // 0x04 << uuid_format => size of UUID, except for UUID_DCE_STRING.
+ UUID_DOS = 0, // 4 bytes
+ UUID_NTFS = 1, // 8 bytes
+ UUID_DCE = 2, // 16 bytes
+ UUID_DCE_STRING = 3, // 36 bytes (VOLUME_ID_UUID_SIZE)
};
enum endian {
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic