Skip to content

Commit

Permalink
11946 clean up improper use of mdb_getopts
Browse files Browse the repository at this point in the history
Portions contributed by: Jason King <jason.king@joyent.com>
Reviewed by: Toomas Soome <tsoome@me.com>
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: John Levon <john.levon@joyent.com>
Approved by: Dan McDonald <danmcd@joyent.com>
  • Loading branch information
jordanhendricks authored and Jason King committed Nov 12, 2019
1 parent d8849d7 commit 3b44223
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 44 deletions.
6 changes: 4 additions & 2 deletions usr/src/cmd/fm/modules/common/eversholt/eft_mdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/mdb_modapi.h>
Expand Down Expand Up @@ -316,8 +318,8 @@ eft_time(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (argc) {
if (mdb_getopts(argc, argv,
'l', MDB_OPT_UINT64, &ull,
'p', MDB_OPT_SETBITS, TRUE, &opt_p,
MDB_OPT_UINT64) != argc) {
'p', MDB_OPT_SETBITS, TRUE, &opt_p, MDB_OPT_UINT64,
NULL) != argc) {
return (DCMD_USAGE);
}
}
Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/mdb/common/mdb/mdb_modapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013 by Delphix. All rights reserved.
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

#ifndef _MDB_MODAPI_H
Expand Down Expand Up @@ -245,7 +245,7 @@ extern int mdb_getareg(mdb_tid_t, const char *, mdb_reg_t *);
#define MDB_OPT_UINT64 5 /* uint64_t argument */
#define MDB_OPT_UINTPTR_SET 6 /* boolean_t+uintptr_t args */

extern int mdb_getopts(int, const mdb_arg_t *, ...);
extern int mdb_getopts(int, const mdb_arg_t *, ...) __sentinel(0);

extern u_longlong_t mdb_strtoull(const char *);

Expand Down
5 changes: 4 additions & 1 deletion usr/src/cmd/mdb/common/modules/cpc/cpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/mdb_modapi.h>
Expand Down Expand Up @@ -57,7 +59,8 @@ cpc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
int j;
uint_t opt_v = FALSE;

if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v, NULL) !=
argc)
return (DCMD_USAGE);

if ((flags & DCMD_ADDRSPEC) == 0) {
Expand Down
7 changes: 4 additions & 3 deletions usr/src/cmd/mdb/common/modules/fctl/fctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/mdb_modapi.h>
Expand Down Expand Up @@ -134,7 +134,7 @@ ports(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}

if (mdb_getopts(argc, argv,
'l', MDB_OPT_SETBITS, TRUE, &longlist) != argc) {
'l', MDB_OPT_SETBITS, TRUE, &longlist, NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down Expand Up @@ -1104,7 +1104,8 @@ fc_trace_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)

if (mdb_getopts(argc, argv,
's', MDB_OPT_UINTPTR, &pktstart,
'e', MDB_OPT_UINTPTR, &pktend) != argc) {
'e', MDB_OPT_UINTPTR, &pktend,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down
5 changes: 4 additions & 1 deletion usr/src/cmd/mdb/common/modules/genunix/fm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -158,7 +160,8 @@ ereport(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (!(flags & DCMD_ADDRSPEC))
return (DCMD_USAGE);

if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v) != argc)
if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &opt_v, NULL) !=
argc)
return (DCMD_USAGE);

if (mdb_vread(&nvl, sizeof (nvl), addr) == -1) {
Expand Down
7 changes: 4 additions & 3 deletions usr/src/cmd/mdb/common/modules/genunix/ldi.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/

/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -290,7 +290,8 @@ ldi_ident(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
}

static void
ldi_handle_header(int refs, int ident) {
ldi_handle_header(int refs, int ident)
{
mdb_printf("%-?s ", "HANDLE");

if (refs)
Expand Down Expand Up @@ -369,7 +370,7 @@ ldi_handle(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
int refs = 1;

if (mdb_getopts(argc, argv,
'i', MDB_OPT_SETBITS, TRUE, &ident) != argc)
'i', MDB_OPT_SETBITS, TRUE, &ident, NULL) != argc)
return (DCMD_USAGE);

if (ident)
Expand Down
4 changes: 2 additions & 2 deletions usr/src/cmd/mdb/common/modules/genunix/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2017 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

#include <mdb/mdb_param.h>
Expand Down Expand Up @@ -696,7 +696,7 @@ pagelookup(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (mdb_getopts(argc, argv,
'v', MDB_OPT_UINTPTR, &vp,
'o', MDB_OPT_UINT64, &offset,
0) != argc) {
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down
6 changes: 3 additions & 3 deletions usr/src/cmd/mdb/common/modules/libumem/umem.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

/*
* Copyright (c) 2018, Joyent, Inc.
* Copyright 2019 Joyent, Inc.
* Copyright (c) 2013, 2015 by Delphix. All rights reserved.
*/

Expand Down Expand Up @@ -4089,7 +4089,7 @@ umem_malloc_dist(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
'g', MDB_OPT_SETBITS, TRUE, &geometric,
'b', MDB_OPT_UINTPTR, &maxbuckets,
'B', MDB_OPT_UINTPTR, &minbucketsize,
0) != argc)
NULL) != argc)
return (DCMD_USAGE);

bzero(&mi, sizeof (mi));
Expand Down Expand Up @@ -4165,7 +4165,7 @@ umem_malloc_info(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
'g', MDB_OPT_SETBITS, TRUE, &geometric,
'b', MDB_OPT_UINTPTR, &maxbuckets,
'B', MDB_OPT_UINTPTR, &minbucketsize,
0) != argc)
NULL) != argc)
return (DCMD_USAGE);

if (dump || geometric || (maxbuckets != 0) || (minbucketsize != 0))
Expand Down
4 changes: 3 additions & 1 deletion usr/src/cmd/mdb/common/modules/pmcs/pmcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Milan Jurik. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

#include <limits.h>
Expand Down Expand Up @@ -2646,7 +2647,8 @@ pmcs_tag(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (mdb_getopts(argc, argv,
'i', MDB_OPT_UINT64, &index,
's', MDB_OPT_UINT64, &snum,
't', MDB_OPT_UINT64, &tag_type) != argc)
't', MDB_OPT_UINT64, &tag_type,
NULL) != argc)
return (DCMD_USAGE);

/*
Expand Down
16 changes: 10 additions & 6 deletions usr/src/cmd/mdb/common/modules/qlc/qlc.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
*
*/

/*
* Copyright 2019 Joyent, Inc.
*/

#pragma ident "Copyright 2010 QLogic Corporation; ql_mdb.c"

#include <sys/mdb_modapi.h>
Expand Down Expand Up @@ -1099,8 +1103,8 @@ qlcstate_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_USAGE);
}

if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
argc) {
if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down Expand Up @@ -1741,8 +1745,8 @@ qlc_getdump_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_USAGE);
}

if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
argc) {
if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down Expand Up @@ -3193,8 +3197,8 @@ qlc_gettrace_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_USAGE);
}

if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose) !=
argc) {
if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down
16 changes: 8 additions & 8 deletions usr/src/cmd/mdb/common/modules/scsi_vhci/scsi_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#pragma ident "%Z%%M% %I% %E% SMI"

#include <sys/kmem.h>
#include <sys/proc.h>
#include <sys/time.h>
Expand Down Expand Up @@ -193,10 +193,10 @@ mdiclient(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
dump_condvar(value.ct_failover_cv, "ct_failover_cv");

mdb_printf("\n");
mdb_printf("ct_failover_flags TEMP_VAR: %8d\n", value.ct_failover_flags)
;
mdb_printf("ct_failover_status UNUSED: %9d\n", value.ct_failover_status)
;
mdb_printf("ct_failover_flags TEMP_VAR: %8d\n",
value.ct_failover_flags);
mdb_printf("ct_failover_status UNUSED: %9d\n",
value.ct_failover_status);

return (DCMD_OK);
}
Expand Down Expand Up @@ -250,7 +250,7 @@ vhciguid(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)


if (flags & DCMD_ADDRSPEC)
mdb_warn("This command doesn't use an address\n");
mdb_warn("This command doesn't use an address\n");

if (i_vhci_states(0, 0, 0, 0, &ss) != DCMD_OK)
return (DCMD_ERR);
Expand Down Expand Up @@ -517,7 +517,7 @@ i_vhci_states(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv,
}
if (sp == NULL) {
if (mdb_getopts(argc, argv,
'v', MDB_OPT_SETBITS, TRUE, &verbose) != argc) {
'v', MDB_OPT_SETBITS, TRUE, &verbose, NULL) != argc) {
return (DCMD_USAGE);
}
}
Expand Down
4 changes: 3 additions & 1 deletion usr/src/cmd/mdb/common/modules/sctp/sctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -726,7 +727,8 @@ sctp(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
'c', MDB_OPT_SETBITS, MDB_SCTP_SHOW_CLOSE, &opts,
'e', MDB_OPT_SETBITS, MDB_SCTP_SHOW_EXT, &opts,
'P', MDB_OPT_SETBITS, 1, &paddr,
'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts) != argc) {
'd', MDB_OPT_SETBITS, MDB_SCTP_DUMP_ADDRS, &opts,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down
4 changes: 3 additions & 1 deletion usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2019 Joyent, Inc.
*/

#include <sys/types.h>
Expand Down Expand Up @@ -78,7 +80,7 @@ sockparams_prt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
*/
if (mdb_getopts(argc, argv,
'e', MDB_OPT_SETBITS, 1, &opt_e,
'E', MDB_OPT_SETBITS, 1, &opt_E) != argc)
'E', MDB_OPT_SETBITS, 1, &opt_E, NULL) != argc)
return (DCMD_USAGE);

if (!opt_E) {
Expand Down
10 changes: 6 additions & 4 deletions usr/src/cmd/mdb/common/modules/zfs/zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2011, 2018 by Delphix. All rights reserved.
* Copyright (c) 2019 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/* Portions Copyright 2010 Robert Milkowski */
Expand Down Expand Up @@ -948,7 +948,8 @@ dbufs(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
'n', MDB_OPT_STR, &data.osname,
'o', MDB_OPT_STR, &object,
'l', MDB_OPT_UINT64, &data.level,
'b', MDB_OPT_STR, &blkid) != argc) {
'b', MDB_OPT_STR, &blkid,
NULL) != argc) {
return (DCMD_USAGE);
}

Expand Down Expand Up @@ -3573,7 +3574,7 @@ zfs_acl_dump(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_USAGE);

if (mdb_getopts(argc, argv,
'v', MDB_OPT_SETBITS, TRUE, &verbose, TRUE, NULL) != argc)
'v', MDB_OPT_SETBITS, TRUE, &verbose, NULL) != argc)
return (DCMD_USAGE);

if (mdb_vread(&zacl, sizeof (zfs_acl_t), addr) == -1) {
Expand Down Expand Up @@ -4006,7 +4007,8 @@ arc_compression_stats(uintptr_t addr, uint_t flags, int argc,
'a', MDB_OPT_SETBITS, ARC_CFLAG_ANON, &data.arc_cflags,
'b', MDB_OPT_SETBITS, ARC_CFLAG_BUFS, &data.arc_cflags,
'r', MDB_OPT_SETBITS, ARC_CFLAG_MRU, &data.arc_cflags,
'f', MDB_OPT_SETBITS, ARC_CFLAG_MFU, &data.arc_cflags) != argc)
'f', MDB_OPT_SETBITS, ARC_CFLAG_MFU, &data.arc_cflags,
NULL) != argc)
return (DCMD_USAGE);

if (mdb_lookup_by_obj(ZFS_OBJ_NAME, "ARC_anon", &data.anon_sym) ||
Expand Down
6 changes: 3 additions & 3 deletions usr/src/cmd/mdb/i86pc/modules/unix/i86mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
* Copyright 2018 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

/*
Expand Down Expand Up @@ -491,7 +491,7 @@ pte_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_USAGE);

if (mdb_getopts(argc, argv,
'l', MDB_OPT_UINT64, &level) != argc)
'l', MDB_OPT_UINT64, &level, NULL) != argc)
return (DCMD_USAGE);

if (level > mmu.max_level) {
Expand Down Expand Up @@ -647,7 +647,7 @@ va2pfn_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);

if (mdb_getopts(argc, argv,
'a', MDB_OPT_STR, &addrspace_str) != argc)
'a', MDB_OPT_STR, &addrspace_str, NULL) != argc)
return (DCMD_USAGE);

if ((flags & DCMD_ADDRSPEC) == 0)
Expand Down
Loading

0 comments on commit 3b44223

Please sign in to comment.