[v4,1/2] lpm: add const to lpm arg of rte_lpm_lookup

Message ID 20220601111542.401360-1-kda@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v4,1/2] lpm: add const to lpm arg of rte_lpm_lookup |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Stanislaw Kardach June 1, 2022, 11:15 a.m. UTC
  All other rte_lpm_lookup* functions take lpm argument as a const. As the
basic rte_lpm_lookup() performs the same function, it should also do
that.

As this function is inline, no API/ABI change happens.

Signed-off-by: Stanislaw Kardach <kda@semihalf.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/lpm/rte_lpm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Thomas Monjalon June 2, 2022, 8:52 p.m. UTC | #1
01/06/2022 13:15, Stanislaw Kardach:
> All other rte_lpm_lookup* functions take lpm argument as a const. As the
> basic rte_lpm_lookup() performs the same function, it should also do
> that.
> 
> As this function is inline, no API/ABI change happens.

It is an API change and should be noted in the release notes.

>  static inline int
> -rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
> +rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
  
Bruce Richardson June 3, 2022, 7:29 a.m. UTC | #2
On Thu, Jun 02, 2022 at 10:52:25PM +0200, Thomas Monjalon wrote:
> 01/06/2022 13:15, Stanislaw Kardach:
> > All other rte_lpm_lookup* functions take lpm argument as a const. As the
> > basic rte_lpm_lookup() performs the same function, it should also do
> > that.
> > 
> > As this function is inline, no API/ABI change happens.
> 
> It is an API change and should be noted in the release notes.
> 
> >  static inline int
> > -rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
> > +rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
>
While I've no particular objection to it appearing in the RN doc, I wonder
whether it really counts as an API change. I can't see any practical
difference that this change would make to the end user - no source code
needs updating for example.

/Bruce
  
Thomas Monjalon June 3, 2022, 7:43 a.m. UTC | #3
03/06/2022 09:29, Bruce Richardson:
> On Thu, Jun 02, 2022 at 10:52:25PM +0200, Thomas Monjalon wrote:
> > 01/06/2022 13:15, Stanislaw Kardach:
> > > All other rte_lpm_lookup* functions take lpm argument as a const. As the
> > > basic rte_lpm_lookup() performs the same function, it should also do
> > > that.
> > > 
> > > As this function is inline, no API/ABI change happens.
> > 
> > It is an API change and should be noted in the release notes.
> > 
> > >  static inline int
> > > -rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
> > > +rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
> >
> While I've no particular objection to it appearing in the RN doc, I wonder
> whether it really counts as an API change. I can't see any practical
> difference that this change would make to the end user - no source code
> needs updating for example.

Yes you're right, we can skip the release notes here.
  

Patch

diff --git a/lib/lpm/rte_lpm.h b/lib/lpm/rte_lpm.h
index eb91960e81..1cf863a146 100644
--- a/lib/lpm/rte_lpm.h
+++ b/lib/lpm/rte_lpm.h
@@ -279,7 +279,7 @@  rte_lpm_delete_all(struct rte_lpm *lpm);
  *   -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
  */
 static inline int
-rte_lpm_lookup(struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
+rte_lpm_lookup(const struct rte_lpm *lpm, uint32_t ip, uint32_t *next_hop)
 {
 	unsigned tbl24_index = (ip >> 8);
 	uint32_t tbl_entry;