Commit 8c988485 authored by Keith Holman's avatar Keith Holman

build: various warning fixes

This patch fixes various warnings produced during the build the most
common warning, is the truncation of "size_t" (usually unsigned long) to
(int).  This patch explicitly casts the result to "int" in these cases
to supress the warning.  Additionally, this patch includes a fix to an
internal library load function to take a "const char *" parameter
instead of a "char *" parameter.
Signed-off-by: 's avatarKeith Holman <keith.holman@windriver.com>
parent 6cc27d6c
......@@ -60,7 +60,7 @@
char* FindString(char* filename, const char* eyecatcher_input);
int printVersionInfo(MQTTAsync_nameValue* info);
int loadandcall(char* libname);
int loadandcall(const char* libname);
void printEyecatchers(char* filename);
......@@ -133,16 +133,14 @@ int printVersionInfo(MQTTAsync_nameValue* info)
typedef MQTTAsync_nameValue* (*func_type)(void);
int loadandcall(char* libname)
int loadandcall(const char* libname)
{
int rc = 0;
MQTTAsync_nameValue* (*func_address)(void) = NULL;
#if defined(WIN32) || defined(WIN64)
wchar_t wlibname[30];
HMODULE APILibrary;
mbstowcs(wlibname, libname, strlen(libname) + 1);
if ((APILibrary = LoadLibrary(wlibname)) == NULL)
if ((APILibrary = LoadLibraryA(libname)) == NULL)
printf("Error loading library %s, error code %d\n", libname, GetLastError());
else
{
......
......@@ -106,7 +106,7 @@ void onConnect(void* context, MQTTAsync_successData* response)
opts.context = client;
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
pubmsg.payloadlen = (int)strlen(PAYLOAD);
pubmsg.qos = QOS;
pubmsg.retained = 0;
deliveredtoken = 0;
......
......@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
exit(EXIT_FAILURE);
}
pubmsg.payload = PAYLOAD;
pubmsg.payloadlen = strlen(PAYLOAD);
pubmsg.payloadlen = (int)strlen(PAYLOAD);
pubmsg.qos = QOS;
pubmsg.retained = 0;
MQTTClient_publishMessage(client, TOPIC, &pubmsg, &token);
......
......@@ -547,7 +547,7 @@ int test2(struct Options options)
opts.MQTTVersion = options.MQTTVersion;
opts.username = "testuser";
opts.binarypwd.data = "testpassword";
opts.binarypwd.len = strlen(opts.binarypwd.data);
opts.binarypwd.len = (int)strlen(opts.binarypwd.data);
if (options.haconnections != NULL)
{
opts.serverURIs = options.haconnections;
......@@ -1068,7 +1068,7 @@ int test6a(struct Options options)
opts.MQTTVersion = MQTTVERSION_3_1_1;
opts.will = &wopts;
opts.will->payload.data = test6_will_message;
opts.will->payload.len = strlen(test6_will_message) + 1;
opts.will->payload.len = (int)strlen(test6_will_message) + 1;
opts.will->qos = 1;
opts.will->retained = 0;
opts.will->topicName = test6_will_topic;
......
......@@ -471,7 +471,7 @@ int test2(struct Options options)
opts.cleansession = 1;
opts.username = "testuser";
opts.binarypwd.data = "testpassword";
opts.binarypwd.len = strlen(opts.binarypwd.data);
opts.binarypwd.len = (int)strlen(opts.binarypwd.data);
opts.MQTTVersion = options.MQTTVersion;
opts.will = &wopts;
......
......@@ -1726,7 +1726,7 @@ int test6(struct Options options)
/* let client c go: connect, and send disconnect command to proxy */
opts.will = &wopts;
opts.will->payload.data = "will message";
opts.will->payload.len = strlen(opts.will->payload.data) + 1;
opts.will->payload.len = (int)strlen(opts.will->payload.data) + 1;
opts.will->qos = 1;
opts.will->retained = 0;
opts.will->topicName = willTopic;
......@@ -1870,7 +1870,6 @@ void test7cOnConnectSuccess(void* context, MQTTAsync_successData* response)
{
MQTTAsync c = (MQTTAsync)context;
MQTTAsync_message pubmsg = MQTTAsync_message_initializer;
int rc;
MyLog(LOGA_DEBUG, "In connect onSuccess callback for client c, context %p\n", context);
......@@ -1904,7 +1903,6 @@ void test7dOnConnectSuccess(void* context, MQTTAsync_successData* response)
{
MQTTAsync c = (MQTTAsync)context;
MQTTAsync_responseOptions opts = MQTTAsync_responseOptions_initializer;
int rc;
int qoss[2] = {2, 2};
char* topics[2] = {willTopic, test_topic};
......@@ -1933,7 +1931,6 @@ int test7(struct Options options)
char clientidc[50];
char clientidd[50];
int i = 0;
MQTTAsync_token *tokens;
test7_will_message_received = 0;
test7_messages_received = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment