Re: [PATCH 1/1] staging: fix bcm/hostmibs.c checkpatch problems

From: Joe Perches
Date: Sun Mar 23 2014 - 13:45:27 EST


On Sat, 2014-03-22 at 09:50 -0600, Jake Edge wrote:
> Fix 4 checkpatch errors, many warnings in bcm/hostmibs.c

Making code checkpatch clean shouldn't be the primary goal here.

Removing uses of Hungarian-style notation, CamelCase naming, and
long variable names would be more helpful overall.

> diff --git a/drivers/staging/bcm/hostmibs.c b/drivers/staging/bcm/hostmibs.c
[]
> @@ -9,27 +9,32 @@
[]
> -INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_mibs *pstHostMibs)
> +INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter,
> + struct bcm_host_stats_mibs *pstHostMibs)
[]
> - struct bcm_phs_extension *pDeviceExtension = (struct bcm_phs_extension *) &Adapter->stBCMPhsContext;
> + struct bcm_phs_extension *pDeviceExtension =
> + (struct bcm_phs_extension *) &Adapter->stBCMPhsContext;

btw: this cast is unnecessary.
&Adapter->stBCMPhsContext is a (struct bcm_phs_extension *)

> - UINT nClassifierIndex = 0, nPhsTableIndex = 0, nSfIndex = 0, uiIndex = 0;
> + UINT nClassifierIndex = 0, nPhsTableIndex = 0,
> + nSfIndex = 0, uiIndex = 0;

Using one initializer per line is generally better.

[]

> /* Copy the classifier Table */
> - for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS; nClassifierIndex++) {
> + for (nClassifierIndex = 0; nClassifierIndex < MAX_CLASSIFIERS;
> + nClassifierIndex++) {
> if (Adapter->astClassifierTable[nClassifierIndex].bUsed == TRUE)
> - memcpy((PVOID) &pstHostMibs->
> + memcpy((PVOID)&pstHostMibs->
> astClassifierTable[nClassifierIndex],
> - (PVOID) &Adapter->
> + (PVOID)&Adapter->
> astClassifierTable[nClassifierIndex],
> sizeof(struct bcm_mibs_classifier_rule));

You could remove the (PVOID) casts here.
mem<foo> pointers don't need to be cast to void,
the compiler already does that.

> @@ -82,53 +88,70 @@ INT ProcessGetHostMibs(struct bcm_mini_adapter *Adapter, struct bcm_host_stats_m
> /* Copy other Host Statistics parameters */
> pstHostMibs->stHostInfo.GoodTransmits = Adapter->dev->stats.tx_packets;
> pstHostMibs->stHostInfo.GoodReceives = Adapter->dev->stats.rx_packets;
> - pstHostMibs->stHostInfo.CurrNumFreeDesc = atomic_read(&Adapter->CurrNumFreeTxDesc);
> + pstHostMibs->stHostInfo.CurrNumFreeDesc =
> + atomic_read(&Adapter->CurrNumFreeTxDesc);
> pstHostMibs->stHostInfo.BEBucketSize = Adapter->BEBucketSize;
> pstHostMibs->stHostInfo.rtPSBucketSize = Adapter->rtPSBucketSize;
> pstHostMibs->stHostInfo.TimerActive = Adapter->TimerActive;
> pstHostMibs->stHostInfo.u32TotalDSD = Adapter->u32TotalDSD;

maybe use a temporary for &pst->stHostInfo and change all
of these to

host_info-><foo> = Adapter-><bar>;


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/