mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-01 22:25:22 +00:00
camcontrol: Use nitems(foo) instead of sizeof(foo)/sizeof(foo[0])
Pull Request: https://github.com/freebsd/freebsd-src/pull/888 Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
This commit is contained in:
parent
c3c816173d
commit
7028e630d6
|
@ -36,7 +36,7 @@
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stdint.h>
|
#include <sys/stdint.h>
|
||||||
#include <sys/types.h>
|
#include <sys/param.h>
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/sbuf.h>
|
#include <sys/sbuf.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
@ -265,7 +265,7 @@ scsiattrib(struct cam_device *device, int argc, char **argv, char *combinedopt,
|
||||||
int entry_num = 0;
|
int entry_num = 0;
|
||||||
|
|
||||||
status = scsi_get_nv(elem_type_map,
|
status = scsi_get_nv(elem_type_map,
|
||||||
sizeof(elem_type_map) / sizeof(elem_type_map[0]),
|
nitems(elem_type_map),
|
||||||
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
||||||
if (status == SCSI_NV_FOUND)
|
if (status == SCSI_NV_FOUND)
|
||||||
element_type = elem_type_map[entry_num].value;
|
element_type = elem_type_map[entry_num].value;
|
||||||
|
|
|
@ -33,10 +33,9 @@
|
||||||
* ATA Extended Power Conditions (EPC) support
|
* ATA Extended Power Conditions (EPC) support
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stdint.h>
|
#include <sys/stdint.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/sbuf.h>
|
#include <sys/sbuf.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
@ -151,7 +150,7 @@ epc_print_pcl_desc(struct ata_power_cond_log_desc *desc, const char *prefix)
|
||||||
max_chars = 75;
|
max_chars = 75;
|
||||||
|
|
||||||
num_printed = printf("%sFlags: ", prefix);
|
num_printed = printf("%sFlags: ", prefix);
|
||||||
for (i = 0; i < (sizeof(epc_flags) / sizeof(epc_flags[0])); i++) {
|
for (i = 0; i < nitems(epc_flags); i++) {
|
||||||
if ((desc->flags & epc_flags[i].value) == 0)
|
if ((desc->flags & epc_flags[i].value) == 0)
|
||||||
continue;
|
continue;
|
||||||
if (first == 0) {
|
if (first == 0) {
|
||||||
|
@ -466,7 +465,7 @@ epc_getmode(struct cam_device *device, camcontrol_devtype devtype,
|
||||||
}
|
}
|
||||||
|
|
||||||
mode_name = scsi_nv_to_str(epc_power_cond_map,
|
mode_name = scsi_nv_to_str(epc_power_cond_map,
|
||||||
sizeof(epc_power_cond_map) / sizeof(epc_power_cond_map[0]), count);
|
nitems(epc_power_cond_map), count);
|
||||||
printf("Current power state: ");
|
printf("Current power state: ");
|
||||||
/* Note: ident can be null in power_only mode */
|
/* Note: ident can be null in power_only mode */
|
||||||
if ((ident == NULL)
|
if ((ident == NULL)
|
||||||
|
@ -638,7 +637,7 @@ epc(struct cam_device *device, int argc, char **argv, char *combinedopt,
|
||||||
int entry_num;
|
int entry_num;
|
||||||
|
|
||||||
status = scsi_get_nv(epc_cmd_map,
|
status = scsi_get_nv(epc_cmd_map,
|
||||||
(sizeof(epc_cmd_map) / sizeof(epc_cmd_map[0])),
|
nitems(epc_cmd_map),
|
||||||
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
||||||
if (status == SCSI_NV_FOUND)
|
if (status == SCSI_NV_FOUND)
|
||||||
action = epc_cmd_map[entry_num].value;
|
action = epc_cmd_map[entry_num].value;
|
||||||
|
@ -715,7 +714,7 @@ epc(struct cam_device *device, int argc, char **argv, char *combinedopt,
|
||||||
int entry_num;
|
int entry_num;
|
||||||
|
|
||||||
status = scsi_get_nv(epc_ps_map,
|
status = scsi_get_nv(epc_ps_map,
|
||||||
(sizeof(epc_ps_map) / sizeof(epc_ps_map[0])),
|
nitems(epc_ps_map),
|
||||||
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
||||||
if (status == SCSI_NV_FOUND)
|
if (status == SCSI_NV_FOUND)
|
||||||
power_src = epc_ps_map[entry_num].value;
|
power_src = epc_ps_map[entry_num].value;
|
||||||
|
|
|
@ -34,10 +34,9 @@
|
||||||
* This is an implementation of the SCSI ZBC and ATA ZAC specs.
|
* This is an implementation of the SCSI ZBC and ATA ZAC specs.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/param.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stdint.h>
|
#include <sys/stdint.h>
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/endian.h>
|
#include <sys/endian.h>
|
||||||
#include <sys/sbuf.h>
|
#include <sys/sbuf.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
|
@ -353,7 +352,7 @@ zone(struct cam_device *device, int argc, char **argv, char *combinedopt,
|
||||||
int entry_num;
|
int entry_num;
|
||||||
|
|
||||||
status = scsi_get_nv(zone_cmd_map,
|
status = scsi_get_nv(zone_cmd_map,
|
||||||
(sizeof(zone_cmd_map) / sizeof(zone_cmd_map[0])),
|
nitems(zone_cmd_map),
|
||||||
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
||||||
if (status == SCSI_NV_FOUND)
|
if (status == SCSI_NV_FOUND)
|
||||||
action = zone_cmd_map[entry_num].value;
|
action = zone_cmd_map[entry_num].value;
|
||||||
|
@ -387,7 +386,7 @@ zone(struct cam_device *device, int argc, char **argv, char *combinedopt,
|
||||||
int entry_num;
|
int entry_num;
|
||||||
|
|
||||||
status = scsi_get_nv(zone_rep_opts,
|
status = scsi_get_nv(zone_rep_opts,
|
||||||
(sizeof(zone_rep_opts) /sizeof(zone_rep_opts[0])),
|
nitems(zone_rep_opts),
|
||||||
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
optarg, &entry_num, SCSI_NV_FLAG_IG_CASE);
|
||||||
if (status == SCSI_NV_FOUND)
|
if (status == SCSI_NV_FOUND)
|
||||||
rep_option = zone_rep_opts[entry_num].value;
|
rep_option = zone_rep_opts[entry_num].value;
|
||||||
|
|
Loading…
Reference in a new issue