Fix compiler warnings related to 'const'

This commit is contained in:
Ronnie Sahlberg
2012-11-11 10:03:45 -08:00
parent a5b8224f4e
commit 9eb26a368d
5 changed files with 33 additions and 12 deletions

View File

@@ -52,7 +52,7 @@ WSADATA wsaData;
struct client_state {
int finished;
char *message;
const char *message;
int has_discovered_target;
char *target_name;
char *target_address;

View File

@@ -24,8 +24,11 @@
#include "iscsi.h"
#include "scsi-lowlevel.h"
const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-inq";
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-inq";
void inquiry_block_limits(struct scsi_inquiry_block_limits *inq)
{
@@ -216,7 +219,7 @@ int main(int argc, const char *argv[])
struct iscsi_context *iscsi;
const char **extra_argv;
int extra_argc = 0;
char *url = NULL;
const char *url = NULL;
struct iscsi_url *iscsi_url = NULL;
int evpd = 0, pagecode = 0;
int show_help = 0, show_usage = 0, debug = 0;
@@ -277,8 +280,10 @@ int main(int argc, const char *argv[])
}
iscsi_url = iscsi_parse_full_url(iscsi, url);
if (url) free(url);
if (url) {
free(discard_const(url));
}
if (iscsi_url == NULL) {
fprintf(stderr, "Failed to parse URL: %s\n",
iscsi_get_error(iscsi));

View File

@@ -24,6 +24,10 @@
#include "iscsi.h"
#include "scsi-lowlevel.h"
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
int showluns;
const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-ls";
@@ -312,7 +316,7 @@ int main(int argc, const char *argv[])
struct client_state state;
const char **extra_argv;
int extra_argc = 0;
char *url = NULL;
const char *url = NULL;
poptContext pc;
int res;
int show_help = 0, show_usage = 0, debug = 0;
@@ -374,8 +378,10 @@ int main(int argc, const char *argv[])
iscsi_url = iscsi_parse_portal_url(iscsi, url);
if (url) free(url);
if (url) {
free(discard_const(url));
}
if (iscsi_url == NULL) {
fprintf(stderr, "Failed to parse URL: %s\n",
iscsi_get_error(iscsi));

View File

@@ -26,6 +26,10 @@
#include "iscsi.h"
#include "scsi-lowlevel.h"
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
const char *initiator = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-readcapacity16";
void print_usage(void)
@@ -58,7 +62,7 @@ int main(int argc, const char *argv[])
struct iscsi_context *iscsi;
const char **extra_argv;
int extra_argc = 0;
char *url = NULL;
const char *url = NULL;
struct iscsi_url *iscsi_url = NULL;
int show_help = 0, show_usage = 0, debug = 0, size_only=0;
int res;
@@ -119,8 +123,10 @@ int main(int argc, const char *argv[])
}
iscsi_url = iscsi_parse_full_url(iscsi, url);
if (url) free(url);
if (url) {
free(discard_const(url));
}
if (iscsi_url == NULL) {
fprintf(stderr, "Failed to parse URL: %s\n",
iscsi_get_error(iscsi));

View File

@@ -34,6 +34,10 @@
#include "iscsi-private.h"
#include "iscsi-test.h"
#ifndef discard_const
#define discard_const(ptr) ((void *)((intptr_t)(ptr)))
#endif
const char *initiatorname1 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test";
const char *initiatorname2 = "iqn.2007-10.com.github:sahlberg:libiscsi:iscsi-test-2";
@@ -478,7 +482,7 @@ int main(int argc, const char *argv[])
free(skipname);
free(testname);
free(url);
free(discard_const(url));
return num_failed ? num_failed : num_skipped ? 77 : 0;
}