osrfCachePutString has the argument key marked as char* where it could be a const char*

Bug #1234816 reported by Nathanael Schilling
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenSRF
Fix Released
Low
Unassigned

Bug Description

In osrf_cache.c, line 55 (or so), we have the following definition of osrfCachePutString:
               int osrfCachePutString( char* key, const char* value, time_t seconds )
There seems to be no reason for the key parameter to be marked as const char*, as it is only really passed to memcached_set, which also takes a pointer to const char (See http://docs.libmemcached.org/memcached_set.html)

This isn't really a bug in the sense that it breaks anything; theoretically marking key as const char* might allow the compiler to optimize something, but the performance gains are irrelevant. However, anyone wanting to pass a const char* to osrfCachePutString needs to currently cast it char*, which is ugly.

Tags: pullrequest
Galen Charlton (gmc)
Changed in opensrf:
importance: Undecided → Low
Revision history for this message
Galen Charlton (gmc) wrote :

I've pushed a patch to improve the const-correctness of osrfCachePut{String,Object} to the user/gmcharlt/lp1234816_osrfCachePutString_const branch of the working/OpenSRF repository:

http://git.evergreen-ils.org/?p=working/OpenSRF.git;a=shortlog;h=refs/heads/user/gmcharlt/lp1234816_osrfCachePutString_const

tags: added: pullrequest
Revision history for this message
Bill Erickson (berick) wrote :

Looks good. Pushed to master.

Changed in opensrf:
status: New → Fix Committed
milestone: none → 2.4.0-alpha
Galen Charlton (gmc)
Changed in opensrf:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.