]> git.ozlabs.org Git - ccan/blobdiff - ccan/iscsi/login.c
ccan: Correct some poor conventions in _info includes
[ccan] / ccan / iscsi / login.c
index ff0d4cce77216895732e53bc841ad6c06c021b8a..db9ee8fcfccb56c1336ca5c1144ff1768d70e4fe 100644 (file)
@@ -1,4 +1,4 @@
-/* 
+/*
    Copyright (C) 2010 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
    
    This program is free software; you can redistribute it and/or modify
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
 
-#define _GNU_SOURCE
+#include "config.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <arpa/inet.h>
+#include <ccan/compiler/compiler.h>
 #include "iscsi.h"
 #include "iscsi-private.h"
 
 int iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *private_data)
 {
        struct iscsi_pdu *pdu;
-       char *str;
+       const char *str;
+       char *astr;
        int ret;
 
        if (iscsi == NULL) {
@@ -62,13 +64,13 @@ int iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *pr
 
 
        /* initiator name */
-       if (asprintf(&str, "InitiatorName=%s", iscsi->initiator_name) == -1) {
+       if (asprintf(&astr, "InitiatorName=%s", iscsi->initiator_name) == -1) {
                printf("asprintf failed\n");
                iscsi_free_pdu(iscsi, pdu);
                return -5;
        }
-       ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)str, strlen(str)+1);
-       free(str);
+       ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)astr, strlen(astr)+1);
+       free(astr);
        if (ret != 0) {
                printf("pdu add data failed\n");
                iscsi_free_pdu(iscsi, pdu);
@@ -77,13 +79,13 @@ int iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *pr
 
        /* optional alias */
        if (iscsi->alias) {
-               if (asprintf(&str, "InitiatorAlias=%s", iscsi->alias) == -1) {
+               if (asprintf(&astr, "InitiatorAlias=%s", iscsi->alias) == -1) {
                        printf("asprintf failed\n");
                        iscsi_free_pdu(iscsi, pdu);
                        return -7;
                }
-               ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)str, strlen(str)+1);
-               free(str);
+               ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)astr, strlen(astr)+1);
+               free(astr);
                if (ret != 0) {
                        printf("pdu add data failed\n");
                        iscsi_free_pdu(iscsi, pdu);
@@ -99,13 +101,13 @@ int iscsi_login_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *pr
                        return -9;
                }
 
-               if (asprintf(&str, "TargetName=%s", iscsi->target_name) == -1) {
+               if (asprintf(&astr, "TargetName=%s", iscsi->target_name) == -1) {
                        printf("asprintf failed\n");
                        iscsi_free_pdu(iscsi, pdu);
                        return -10;
                }
-               ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)str, strlen(str)+1);
-               free(str);
+               ret = iscsi_pdu_add_data(iscsi, pdu, (unsigned char *)astr, strlen(astr)+1);
+               free(astr);
                if (ret != 0) {
                        printf("pdu add data failed\n");
                        iscsi_free_pdu(iscsi, pdu);
@@ -204,7 +206,7 @@ int iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu
        int status;
 
        if (size < ISCSI_HEADER_SIZE) {
-               printf("dont have enough data to read status from login reply\n");
+               printf("don't have enough data to read status from login reply\n");
                return -1;
        }
 
@@ -212,7 +214,7 @@ int iscsi_process_login_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu
         *     some parameters.
         *     we should also do proper handshaking if the target is not yet prepared to transition
         *     to the next stage
-        */ 
+        */
        status = ntohs(*(uint16_t *)&hdr[36]);
        if (status != 0) {
                pdu->callback(iscsi, ISCSI_STATUS_ERROR, NULL, pdu->private_data);
@@ -267,7 +269,7 @@ int iscsi_logout_async(struct iscsi_context *iscsi, iscsi_command_cb cb, void *p
        return 0;
 }
 
-int iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, const unsigned char *hdr, int size _U_)
+int iscsi_process_logout_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu, const unsigned char *hdr, int size UNUSED)
 {
        iscsi->is_loggedin = 0;
        pdu->callback(iscsi, ISCSI_STATUS_GOOD, NULL, pdu->private_data);