summaryrefslogtreecommitdiffstats
path: root/sbin/camcontrol
diff options
context:
space:
mode:
authorkbyanc <kbyanc@FreeBSD.org>2000-08-10 01:20:43 +0000
committerkbyanc <kbyanc@FreeBSD.org>2000-08-10 01:20:43 +0000
commit31b5d7188bc34f0a0464d8b0b0aefb55ee3f542b (patch)
treeb4d8fc1de37a23086ac4a1c9eba8ad15a4651689 /sbin/camcontrol
parent831e0f784bedd315e6acefc490380b6c50b11a4c (diff)
downloadFreeBSD-src-31b5d7188bc34f0a0464d8b0b0aefb55ee3f542b.zip
FreeBSD-src-31b5d7188bc34f0a0464d8b0b0aefb55ee3f542b.tar.gz
Fix an order-of-operations bug and properly shift page_control values for
comparison with SMS_PAGE_CTRL_* macros.
Diffstat (limited to 'sbin/camcontrol')
-rw-r--r--sbin/camcontrol/modeedit.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/sbin/camcontrol/modeedit.c b/sbin/camcontrol/modeedit.c
index 735c6b1..7614905 100644
--- a/sbin/camcontrol/modeedit.c
+++ b/sbin/camcontrol/modeedit.c
@@ -63,6 +63,7 @@ int verbose = 0;
#define PAGENAME_END '"' /* Page name delimiter. */
#define PAGEENTRY_END ';' /* Page entry terminator (optional). */
#define MAX_COMMAND_SIZE 255 /* Mode/Log sense data buffer size. */
+#define PAGE_CTRL_SHIFT 6 /* Bit offset to page control field. */
/* Macros for working with mode pages. */
@@ -252,7 +253,7 @@ editentry_set(char *name, char *newvalue, int editonly)
* currently workaround it (even for int64's), so we have to kludge it.
*/
#define RESOLUTION_MAX(size) ((resolution * (size) == 32)? \
- 0xffffffff: 1 << (resolution * (size)) - 1)
+ 0xffffffff: (1 << (resolution * (size))) - 1)
assert(newvalue != NULL);
if (*newvalue == '\0')
@@ -606,9 +607,10 @@ editlist_save(struct cam_device *device, int modepage, int page_control,
* page 3 (saved values) then request the changes be permanently
* recorded.
*/
- mode_select(device, (page_control == SMS_PAGE_CTRL_SAVED), retries,
- timeout, (u_int8_t *)mh, sizeof(*mh) + mh->blk_desc_len +
- sizeof(*mph) + mph->page_length);
+ mode_select(device,
+ (page_control << PAGE_CTRL_SHIFT == SMS_PAGE_CTRL_SAVED),
+ retries, timeout, (u_int8_t *)mh,
+ sizeof(*mh) + mh->blk_desc_len + sizeof(*mph) + mph->page_length);
}
static int
@@ -847,8 +849,8 @@ mode_edit(struct cam_device *device, int page, int page_control, int dbd,
}
if (edit) {
- if (page_control != SMS_PAGE_CTRL_CURRENT &&
- page_control != SMS_PAGE_CTRL_SAVED)
+ if (page_control << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_CURRENT &&
+ page_control << PAGE_CTRL_SHIFT != SMS_PAGE_CTRL_SAVED)
errx(EX_USAGE, "it only makes sense to edit page 0 "
"(current) or page 3 (saved values)");
modepage_edit();
OpenPOWER on IntegriCloud