Fix warnings

This commit is contained in:
Wojtek Figat
2021-02-24 20:12:13 +01:00
parent 6f3e7bc253
commit d4b2171c19
4 changed files with 26 additions and 26 deletions

View File

@@ -169,7 +169,7 @@ char* urlencode(const char* mb_input){
/* For compatibility with our former encoding model... */
unsigned int encodeURIComponent(char input[], char output[], const unsigned int input_len, const unsigned int output_max){
unsigned int encodeURIComponent(const char input[], char output[], const unsigned int input_len, const unsigned int output_max){
return (unsigned int)urlencode_put(output, output_max, input, input_len);
}

View File

@@ -20,9 +20,9 @@ char* urlencode(const char* input);
size_t urlencode_put(char* result, size_t result_max, const char *mb_input, size_t input_len);
// For compatibility..
unsigned int encodeURIComponent(char input[], char output[], const unsigned int input_len, const unsigned int output_max);
unsigned int encodeURIComponent(const char input[], char output[], const unsigned int input_len, const unsigned int output_max);
unsigned int hexdigest(char* hex_output, unsigned char* md5_binary, unsigned int binary_len);
#endif /* UA_ENCODE_H */
#endif /* UA_ENCODE_H */

View File

@@ -26,7 +26,7 @@ static const char UA_PROTOCOL_VERSION[] = "1";
/* Define tracking type strings; these are protocol-constants for
* Measurement Protocol v1. We may eventually migrate these to a separate
* protocol module. */
static inline int populateTypeNames(char* types[]){
static inline int populateTypeNames(const char* types[]){
types[UA_PAGEVIEW] = "pageview";
types[UA_APPVIEW] = "screenview";
types[UA_SCREENVIEW] = "screenview";
@@ -44,7 +44,7 @@ static inline int populateTypeNames(char* types[]){
/* List of parameter names (strings) corresponding to our field indexes;
* these are also protocol-constants for Measurement Protocol v1.
* We may eventually migrate these to a separate protocol module. */
static inline void populateParameterNames(char* params[], const char* custom_params){
static inline void populateParameterNames(const char* params[], const char* custom_params){
int i, j;
char* cur;
params[UA_TRACKING_ID] = "tid";
@@ -136,7 +136,7 @@ static inline void populateParameterNames(char* params[], const char* custom_par
/* Retrieve a field name (pointer) by its ID
* (and appropriate offset for custom parameters */
static inline char* getOptionName(char* field_names[], trackingField_t field, unsigned int slot_id){
static inline const char* getOptionName(const char* field_names[], trackingField_t field, unsigned int slot_id){
switch(field){
case UA_CUSTOM_METRIC:
return field_names[ UA_START_CMETRICS + slot_id - 1 ];
@@ -161,7 +161,7 @@ static inline int getFieldPosition(trackingField_t field, unsigned int slot_id){
/* Retrieve the tracking-type parameter name (pointer) */
static inline char* getTrackingType(UATracker_t* tracker, trackingType_t type){
static inline const char* getTrackingType(UATracker_t* tracker, trackingType_t type){
assert(NULL != tracker);
assert((*tracker).__configured__ == UA_MEM_MAGIC_CONFIG);
@@ -196,9 +196,9 @@ static inline void resetQuery(UATracker_t* tracker){
/* Define a single parameter's name/value/slot */
static inline void setParameterCore(char* field_names[], UAParameter_t params[], trackingField_t field, unsigned int slot_id, const char* value){
static inline void setParameterCore(const char* field_names[], UAParameter_t params[], trackingField_t field, unsigned int slot_id, const char* value){
int position = getFieldPosition(field, slot_id);
char* name = getOptionName(field_names, field, slot_id);
const char* name = getOptionName(field_names, field, slot_id);
assert(NULL != name);
params[ position ].field = field;
params[ position ].name = name;
@@ -207,7 +207,7 @@ static inline void setParameterCore(char* field_names[], UAParameter_t params[],
}
/* Populate several parameters (pointers) given a set of options */
static inline void setParameterList(char* field_names[], UAParameter_t params[], UAOptionNode_t options[], unsigned int howmany){
static inline void setParameterList(const char* field_names[], UAParameter_t params[], UAOptionNode_t options[], unsigned int howmany){
unsigned int i;
for(i = 0; i < howmany; i++){
if(options[i].field < 1){
@@ -235,7 +235,7 @@ static inline void setParameterStateList(UATracker_t* tracker, stateScopeFlag_t
/* Populate a single lifetime/permanent or temporary/ephemeral value based on scope */
static inline void setParameterState(UATracker_t* tracker, stateScopeFlag_t flag, trackingField_t field, unsigned int slot_id, char* value ){
static inline void setParameterState(UATracker_t* tracker, stateScopeFlag_t flag, trackingField_t field, unsigned int slot_id, const char* value ){
assert(NULL != tracker);
assert((*tracker).__configured__ == UA_MEM_MAGIC_CONFIG);
switch(flag){
@@ -266,7 +266,7 @@ int getTrackerOption(UATracker_t* tracker, UATrackerOption_t option){
* - Populate parameter names
* - Define lifetime tracker values
*/
void initTracker(UATracker_t* tracker, char* trackingId, char* clientId, char* userId){
void initTracker(UATracker_t* tracker, const char* trackingId, const char* clientId, const char* userId){
assert(NULL != tracker);
cleanTracker(tracker);
@@ -292,7 +292,7 @@ void initTracker(UATracker_t* tracker, char* trackingId, char* clientId, char* u
}
/* Allocate space for a tracker & initialize it */
UATracker_t* createTracker(char* trackingId, char* clientId, char* userId){
UATracker_t* createTracker(const char* trackingId, const char* clientId, const char* userId){
UATracker_t* new_tracker = (UATracker_t*)malloc(sizeof(UATracker_t));
initTracker(new_tracker, trackingId, clientId, userId);
return new_tracker;
@@ -312,12 +312,12 @@ void setParameters(UATracker_t* tracker, UAOptions_t* opts){
}
/* Wrapper: set up a single lifetime option on a tracker */
void setParameter(UATracker_t* tracker, trackingField_t field, unsigned int slot_id, char* value){
void setParameter(UATracker_t* tracker, trackingField_t field, unsigned int slot_id, const char* value){
setParameterState(tracker, UA_PERMANENT, field, slot_id, value);
}
/* Retrieve name and value for a given index (transcending ephemeral state to lifetime, if needed) */
void getCurrentParameterValue(UATracker_t* tracker, unsigned int index, char** name, char** value){
void getCurrentParameterValue(UATracker_t* tracker, unsigned int index, const char** name, const char** value){
assert(NULL != tracker);
(*name) = tracker->ephemeral_parameters[ index ].name;
@@ -331,14 +331,14 @@ void getCurrentParameterValue(UATracker_t* tracker, unsigned int index, char** n
/* Construct a query-string based on tracker state */
unsigned int assembleQueryString(UATracker_t* tracker, char* query, unsigned int offset){
unsigned int i;
char* name;
char* value;
const char* name;
const char* value;
int name_len;
char* current;
unsigned int value_len;
// Shortcut for client_id for more readable assertion below
char* client_id = tracker->map_parameters[UA_CLIENT_ID];
const char* client_id = tracker->map_parameters[UA_CLIENT_ID];
for(i = 0; i < UA_MAX_PARAMETERS; i++){

View File

@@ -136,8 +136,8 @@ typedef enum trackingField {
typedef struct UAParameter_t {
trackingField_t field;
unsigned int slot_id;
char* name;
char* value;
const char* name;
const char* value;
} UAParameter_t;
/* Flag to specify which level of tracker state to update */
@@ -173,12 +173,12 @@ typedef struct UATracker_t {
/* Standard parameter names (e.g. cid, tid, ea, ec...)
* These are populated in stack space by |populateParameterNames|
* during tracker initialization */
char* map_parameters[ UA_MAX_PARAMETERS ];
const char* map_parameters[ UA_MAX_PARAMETERS ];
/* Standard tracking type names (e.g. pageview, event, etc)
* These are populated in stack space by |populateTypeNames|
* during tracker initialization */
char* map_types[ UA_MAX_TYPES ];
const char* map_types[ UA_MAX_TYPES ];
/* Placeholder for HTTP "User-Agent" header */
const char* user_agent;
@@ -197,7 +197,7 @@ typedef struct UATracker_t {
typedef struct UAOptionNode_t {
trackingField_t field;
unsigned int slot_id;
char* value;
const char* value;
} UAOptionNode_t;
/* List of options (field/value pairs with slot ID */
@@ -215,10 +215,10 @@ typedef UAOptions_t UAOptions;
/* Creates Google Analytics tracker state objects */
UATracker createTracker(char* trackingId, char* clientId, char* userId);
UATracker createTracker(const char* trackingId, const char* clientId, const char* userId);
/* Initialize tracker state */
void initTracker(UATracker tracker, char* trackingId, char* clientId, char* userId);
void initTracker(UATracker tracker, const char* trackingId, const char* clientId, const char* userId);
/* Set flags to tune the funcionality of the tracker */
void setTrackerOption(UATracker tracker, UATrackerOption_t option, int value);
@@ -227,7 +227,7 @@ void setTrackerOption(UATracker tracker, UATrackerOption_t option, int value);
void setParameters(UATracker tracker, UAOptions_t* opts);
/* Store a single option-value pair */
void setParameter(UATracker tracker, trackingField_t type, unsigned int slot_id, char* value);
void setParameter(UATracker tracker, trackingField_t type, unsigned int slot_id, const char* value);
/* Processes tracker state with a tracking type and ephemeral options
* Dispatches resulting query to Google Analytics */