Skip to content

Commit

Permalink
12726 sbbc: smatch and NULL pointer errors
Browse files Browse the repository at this point in the history
Reviewed by: C Fraire <cfraire@me.com>
Reviewed by: Robert Mustacchi <rm@fingolfin.org>
Approved by: Joshua M. Clulow <josh@sysmgr.org>
  • Loading branch information
tsoome committed May 15, 2020
1 parent 4a6e213 commit 836be2f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 38 deletions.
36 changes: 19 additions & 17 deletions usr/src/uts/sun4u/io/sbbc.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ static struct bus_ops sbbc_bus_ops = {
0,
0,
0,
NULL, /* (*bus_map_fault)() */
NULL, /* (*bus_map_fault)() */
ddi_no_dma_map,
ddi_no_dma_allochdl,
ddi_no_dma_freehdl, /* (*bus_dma_freehdl)() */
ddi_no_dma_bindhdl, /* (*bus_dma_bindhdl)() */
ddi_no_dma_unbindhdl, /* (*bus_dma_unbindhdl)() */
ddi_no_dma_flush, /* (*bus_dma_flush)() */
ddi_no_dma_win, /* (*bus_dma_win)() */
ddi_no_dma_mctl, /* (*bus_dma_ctl)() */
ddi_no_dma_freehdl, /* (*bus_dma_freehdl)() */
ddi_no_dma_bindhdl, /* (*bus_dma_bindhdl)() */
ddi_no_dma_unbindhdl, /* (*bus_dma_unbindhdl)() */
ddi_no_dma_flush, /* (*bus_dma_flush)() */
ddi_no_dma_win, /* (*bus_dma_win)() */
ddi_no_dma_mctl, /* (*bus_dma_ctl)() */
sbbc_ctlops,
ddi_bus_prop_op,
0, /* (*bus_get_eventcookie)(); */
Expand Down Expand Up @@ -425,7 +425,7 @@ sbbc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
(void) sprintf(name, "sbbc%d", instance);

if (ddi_create_minor_node(dip, name, S_IFCHR, instance, NULL,
NULL) == DDI_FAILURE) {
0) == DDI_FAILURE) {
ddi_remove_minor_node(dip, NULL);
goto failed;
}
Expand Down Expand Up @@ -510,7 +510,7 @@ sbbc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
*/
static int
sbbc_busmap(dev_info_t *dip, dev_info_t *rdip, ddi_map_req_t *mp,
off_t off, off_t len, caddr_t *addrp)
off_t off, off_t len, caddr_t *addrp)
{
struct sbbcsoft *sbbcsoftp;
sbbc_child_regspec_t *child_rp, *child_regs;
Expand Down Expand Up @@ -690,7 +690,7 @@ sbbc_add_intr_impl(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
childintr->status = SBBC_INTR_STATE_DISABLE;

for (i = 0; i < MAX_SBBC_DEVICES; i++) {
if (sbbcsoftp->child_intr[i] == 0) {
if (sbbcsoftp->child_intr[i] == NULL) {
sbbcsoftp->child_intr[i] = childintr;
break;
}
Expand All @@ -705,7 +705,8 @@ sbbc_add_intr_impl(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
cmn_err(CE_WARN, "sbbc%d: failed to add intr for %s",
instance, ddi_get_name(rdip));
kmem_free(childintr, sizeof (struct sbbc_child_intr));
sbbcsoftp->child_intr[i] = NULL;
if (i < MAX_SBBC_DEVICES)
sbbcsoftp->child_intr[i] = NULL;
}

/*
Expand Down Expand Up @@ -817,7 +818,7 @@ sbbc_update_intr_state(dev_info_t *dip, dev_info_t *rdip, ddi_intr_op_t intr_op,
*/
static int
sbbc_ctlops(dev_info_t *dip, dev_info_t *rdip, ddi_ctl_enum_t op,
void *arg, void *result)
void *arg, void *result)
{
sbbc_child_regspec_t *child_rp;
int i, n;
Expand Down Expand Up @@ -1121,7 +1122,7 @@ sbbc_close(dev_t dev, int flag, int otype, cred_t *credp)
/*ARGSUSED2*/
static int
sbbc_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
int *rvalp)
int *rvalp)
{
struct sbbcsoft *sbbcsoftp;

Expand All @@ -1144,7 +1145,7 @@ sbbc_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
return (EINVAL);
}

if (arg == NULL) {
if (arg == (intptr_t)NULL) {
return (ENXIO);
}

Expand Down Expand Up @@ -1184,7 +1185,7 @@ sbbc_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
return (EINVAL);
}

if (arg == NULL) {
if (arg == (intptr_t)NULL) {
return (ENXIO);
}

Expand Down Expand Up @@ -1372,7 +1373,8 @@ sbbc_intr_wrapper(caddr_t arg)
* used to crash the system.
*/
static int
sbbc_offset_valid(uint32_t offset) {
sbbc_offset_valid(uint32_t offset)
{
/*
* Check for proper alignment first.
*/
Expand Down Expand Up @@ -1415,7 +1417,7 @@ sbbc_offset_valid(uint32_t offset) {
#ifdef DEBUG
void
sbbc_dbg(uint32_t flag, dev_info_t *dip, char *fmt,
uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5)
uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5)
{
char *s = NULL;

Expand Down
21 changes: 0 additions & 21 deletions usr/src/uts/sun4u/sbbc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ UTSBASE = ../..
#
MODULE = sbbc
OBJECTS = $(SBBC_OBJS:%=$(OBJS_DIR)/%)
LINTS = $(SBBC_OBJS:%.o=$(LINTS_DIR)/%.ln)
ROOTMODULE = $(ROOT_PSM_DRV_DIR)/$(MODULE)

#
Expand All @@ -52,30 +51,16 @@ include $(UTSBASE)/sun4u/Makefile.sun4u
# Define targets
#
ALL_TARGET = $(BINARY)
LINT_TARGET = $(MODULE).lint
INSTALL_TARGET = $(BINARY) $(ROOTMODULE)

# Turn this on once compiler understands v9 in it's backend
#INLINES += $(UTSBASE)/sun4u/io/sbbc.il

#
# lint pass one enforcement
#
CFLAGS += $(CCVERBOSE)

#
# Turn on doubleword alignment for 64 bit registers
#
CFLAGS += -dalign

#
# For now, disable these lint checks; maintainers should endeavor
# to investigate and remove these for maximum lint coverage.
# Please do not carry these forward to new Makefiles.
#
LINTTAGS += -erroff=E_BAD_PTR_CAST_ALIGN
LINTTAGS += -erroff=E_ASSIGN_NARROW_CONV

CERRWARN += -_gcc=-Wno-switch

#
Expand All @@ -91,12 +76,6 @@ clean: $(CLEAN_DEPS)

clobber: $(CLOBBER_DEPS)

lint: $(LINT_DEPS)

modlintlib: $(MODLINTLIB_DEPS)

clean.lint: $(CLEAN_LINT_DEPS)

install: $(INSTALL_DEPS)

#
Expand Down

0 comments on commit 836be2f

Please sign in to comment.