mirror of
https://github.com/iustin/mt-st.git
synced 2026-01-03 10:55:15 +00:00
Remove left-shifting of negative values
Left-shifting of negative values is undefined behaviour according to the C standard, because it depends on the exact representation. This code, copied from the Linux kernel, is intended for 2's complement and can be replaced by well-defined behaviour: ~(-1<<N) is equivalent to (1<<N)-1. Signed-off-by: Iustin Pop <iustin@k1024.org>
This commit is contained in:
5
mt.c
5
mt.c
@@ -682,8 +682,9 @@ static int do_status(int mtfd,
|
||||
#define ST_NBR_MODES (1 << ST_NBR_MODE_BITS)
|
||||
#define ST_MODE_SHIFT (7 - ST_NBR_MODE_BITS)
|
||||
#define ST_MODE_MASK ((ST_NBR_MODES - 1) << ST_MODE_SHIFT)
|
||||
#define TAPE_NR(minor) \
|
||||
((((minor) & ~255) >> (ST_NBR_MODE_BITS + 1)) | ((minor) & ~(-1 << ST_MODE_SHIFT)))
|
||||
#define TAPE_NR(minor) \
|
||||
((((minor) & ~255) >> (ST_NBR_MODE_BITS + 1)) | \
|
||||
((minor) & ((1 << ST_MODE_SHIFT) - 1)))
|
||||
#define TAPE_MODE(minor) (((minor)&ST_MODE_MASK) >> ST_MODE_SHIFT)
|
||||
static const char *st_formats[] = { "", "r", "k", "s", "l", "t", "o", "u",
|
||||
"m", "v", "p", "x", "a", "y", "q", "z" };
|
||||
|
||||
Reference in New Issue
Block a user