diff options
author | David Barksdale <amatus.amongus@gmail.com> | 2015-07-19 15:35:07 +0000 |
---|---|---|
committer | David Barksdale <amatus.amongus@gmail.com> | 2015-07-19 15:35:07 +0000 |
commit | a5e12b53160fbf359dd469408c600f0eb976590b (patch) | |
tree | e59bee9ea565e3f9a3f976d939d4c566f29563d5 /src | |
parent | bba1229ab25ed0ae236c3062e371bb97d9a05375 (diff) | |
download | gnunet-a5e12b53160fbf359dd469408c600f0eb976590b.tar.gz gnunet-a5e12b53160fbf359dd469408c600f0eb976590b.zip |
Remove this GNUNET_htonl_signed nonsense
Diffstat (limited to 'src')
-rw-r--r-- | src/include/gnunet_common.h | 76 | ||||
-rw-r--r-- | src/psyc/gnunet-service-psyc.c | 12 | ||||
-rw-r--r-- | src/psyc/psyc_api.c | 6 | ||||
-rw-r--r-- | src/social/gnunet-service-social.c | 4 | ||||
-rw-r--r-- | src/social/social_api.c | 2 | ||||
-rw-r--r-- | src/util/common_endian.c | 43 |
6 files changed, 14 insertions, 129 deletions
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h index 24b922aad..c082398f8 100644 --- a/src/include/gnunet_common.h +++ b/src/include/gnunet_common.h | |||
@@ -727,9 +727,9 @@ GNUNET_ntohll (uint64_t n); | |||
727 | * Convert double to network byte order. | 727 | * Convert double to network byte order. |
728 | * | 728 | * |
729 | * @param d | 729 | * @param d |
730 | * The value in network byte order. | 730 | * The value in host byte order. |
731 | * | 731 | * |
732 | * @return The same value in host byte order. | 732 | * @return The same value in network byte order. |
733 | */ | 733 | */ |
734 | double | 734 | double |
735 | GNUNET_hton_double (double d); | 735 | GNUNET_hton_double (double d); |
@@ -747,78 +747,6 @@ double | |||
747 | GNUNET_ntoh_double (double d); | 747 | GNUNET_ntoh_double (double d); |
748 | 748 | ||
749 | 749 | ||
750 | /** | ||
751 | * Convert signed 64-bit integer to network byte order. | ||
752 | * | ||
753 | * @param n | ||
754 | * The value in host byte order. | ||
755 | * | ||
756 | * @return The same value in network byte order. | ||
757 | */ | ||
758 | uint64_t | ||
759 | GNUNET_htonll_signed (int64_t n); | ||
760 | |||
761 | |||
762 | /** | ||
763 | * Convert signed 64-bit integer to host byte order. | ||
764 | * | ||
765 | * @param n | ||
766 | * The value in network byte order. | ||
767 | * | ||
768 | * @return The same value in host byte order. | ||
769 | */ | ||
770 | int64_t | ||
771 | GNUNET_ntohll_signed (uint64_t n); | ||
772 | |||
773 | |||
774 | /** | ||
775 | * Convert signed 32-bit integer to network byte order. | ||
776 | * | ||
777 | * @param n | ||
778 | * The value in host byte order. | ||
779 | * | ||
780 | * @return The same value in network byte order. | ||
781 | */ | ||
782 | uint32_t | ||
783 | GNUNET_htonl_signed (int32_t n); | ||
784 | |||
785 | |||
786 | /** | ||
787 | * Convert signed 32-bit integer to host byte order. | ||
788 | * | ||
789 | * @param n | ||
790 | * The value in network byte order. | ||
791 | * | ||
792 | * @return The same value in host byte order. | ||
793 | */ | ||
794 | int32_t | ||
795 | GNUNET_ntohl_signed (uint32_t n); | ||
796 | |||
797 | |||
798 | /** | ||
799 | * Convert signed 16-bit integer to network byte order. | ||
800 | * | ||
801 | * @param n | ||
802 | * The value in host byte order. | ||
803 | * | ||
804 | * @return The same value in network byte order. | ||
805 | */ | ||
806 | uint16_t | ||
807 | GNUNET_htons_signed (int16_t n); | ||
808 | |||
809 | |||
810 | /** | ||
811 | * Convert signed 16-bit integer to host byte order. | ||
812 | * | ||
813 | * @param n | ||
814 | * The value in network byte order. | ||
815 | * | ||
816 | * @return The same value in host byte order. | ||
817 | */ | ||
818 | int16_t | ||
819 | GNUNET_ntohs_signed (uint16_t n); | ||
820 | |||
821 | |||
822 | /* ************************* allocation functions ****************** */ | 750 | /* ************************* allocation functions ****************** */ |
823 | 751 | ||
824 | /** | 752 | /** |
diff --git a/src/psyc/gnunet-service-psyc.c b/src/psyc/gnunet-service-psyc.c index 29ef07f10..4c34f6108 100644 --- a/src/psyc/gnunet-service-psyc.c +++ b/src/psyc/gnunet-service-psyc.c | |||
@@ -653,7 +653,7 @@ client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id, | |||
653 | res = GNUNET_malloc (sizeof (*res) + data_size); | 653 | res = GNUNET_malloc (sizeof (*res) + data_size); |
654 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); | 654 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); |
655 | res->header.size = htons (sizeof (*res) + data_size); | 655 | res->header.size = htons (sizeof (*res) + data_size); |
656 | res->result_code = GNUNET_htonll_signed (result_code); | 656 | res->result_code = GNUNET_htonll (result_code); |
657 | res->op_id = op_id; | 657 | res->op_id = op_id; |
658 | if (0 < data_size) | 658 | if (0 < data_size) |
659 | memcpy (&res[1], data, data_size); | 659 | memcpy (&res[1], data, data_size); |
@@ -1544,7 +1544,7 @@ store_recv_master_counters (void *cls, int result, uint64_t max_fragment_id, | |||
1544 | struct GNUNET_PSYC_CountersResultMessage res; | 1544 | struct GNUNET_PSYC_CountersResultMessage res; |
1545 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK); | 1545 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK); |
1546 | res.header.size = htons (sizeof (res)); | 1546 | res.header.size = htons (sizeof (res)); |
1547 | res.result_code = GNUNET_htonl_signed (result); | 1547 | res.result_code = htonl (result); |
1548 | res.max_message_id = GNUNET_htonll (max_message_id); | 1548 | res.max_message_id = GNUNET_htonll (max_message_id); |
1549 | 1549 | ||
1550 | if (GNUNET_OK == result || GNUNET_NO == result) | 1550 | if (GNUNET_OK == result || GNUNET_NO == result) |
@@ -1590,7 +1590,7 @@ store_recv_slave_counters (void *cls, int result, uint64_t max_fragment_id, | |||
1590 | struct GNUNET_PSYC_CountersResultMessage res; | 1590 | struct GNUNET_PSYC_CountersResultMessage res; |
1591 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK); | 1591 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK); |
1592 | res.header.size = htons (sizeof (res)); | 1592 | res.header.size = htons (sizeof (res)); |
1593 | res.result_code = GNUNET_htonl_signed (result); | 1593 | res.result_code = htonl (result); |
1594 | res.max_message_id = GNUNET_htonll (max_message_id); | 1594 | res.max_message_id = GNUNET_htonll (max_message_id); |
1595 | 1595 | ||
1596 | if (GNUNET_OK == result || GNUNET_NO == result) | 1596 | if (GNUNET_OK == result || GNUNET_NO == result) |
@@ -1680,7 +1680,7 @@ client_recv_master_start (void *cls, struct GNUNET_SERVER_Client *client, | |||
1680 | struct GNUNET_PSYC_CountersResultMessage res; | 1680 | struct GNUNET_PSYC_CountersResultMessage res; |
1681 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK); | 1681 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_MASTER_START_ACK); |
1682 | res.header.size = htons (sizeof (res)); | 1682 | res.header.size = htons (sizeof (res)); |
1683 | res.result_code = GNUNET_htonl_signed (GNUNET_OK); | 1683 | res.result_code = htonl (GNUNET_OK); |
1684 | res.max_message_id = GNUNET_htonll (mst->max_message_id); | 1684 | res.max_message_id = GNUNET_htonll (mst->max_message_id); |
1685 | 1685 | ||
1686 | GNUNET_SERVER_notification_context_add (nc, client); | 1686 | GNUNET_SERVER_notification_context_add (nc, client); |
@@ -1791,7 +1791,7 @@ client_recv_slave_join (void *cls, struct GNUNET_SERVER_Client *client, | |||
1791 | struct GNUNET_PSYC_CountersResultMessage res; | 1791 | struct GNUNET_PSYC_CountersResultMessage res; |
1792 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK); | 1792 | res.header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_SLAVE_JOIN_ACK); |
1793 | res.header.size = htons (sizeof (res)); | 1793 | res.header.size = htons (sizeof (res)); |
1794 | res.result_code = GNUNET_htonl_signed (GNUNET_OK); | 1794 | res.result_code = htonl (GNUNET_OK); |
1795 | res.max_message_id = GNUNET_htonll (chn->max_message_id); | 1795 | res.max_message_id = GNUNET_htonll (chn->max_message_id); |
1796 | 1796 | ||
1797 | GNUNET_SERVER_notification_context_add (nc, client); | 1797 | GNUNET_SERVER_notification_context_add (nc, client); |
@@ -2310,7 +2310,7 @@ store_recv_fragment_history (void *cls, | |||
2310 | res->header.size = htons (sizeof (*res) + psize); | 2310 | res->header.size = htons (sizeof (*res) + psize); |
2311 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_HISTORY_RESULT); | 2311 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_HISTORY_RESULT); |
2312 | res->op_id = op->op_id; | 2312 | res->op_id = op->op_id; |
2313 | res->result_code = GNUNET_htonll_signed (GNUNET_OK); | 2313 | res->result_code = GNUNET_htonll (GNUNET_OK); |
2314 | 2314 | ||
2315 | pmsg = (struct GNUNET_PSYC_MessageHeader *) &res[1]; | 2315 | pmsg = (struct GNUNET_PSYC_MessageHeader *) &res[1]; |
2316 | psyc_msg_init (pmsg, mmsg, flags | GNUNET_PSYC_MESSAGE_HISTORIC); | 2316 | psyc_msg_init (pmsg, mmsg, flags | GNUNET_PSYC_MESSAGE_HISTORIC); |
diff --git a/src/psyc/psyc_api.c b/src/psyc/psyc_api.c index 048257bdc..5fc5391a0 100644 --- a/src/psyc/psyc_api.c +++ b/src/psyc/psyc_api.c | |||
@@ -263,7 +263,7 @@ channel_recv_result (void *cls, | |||
263 | uint16_t data_size = size - sizeof (*res); | 263 | uint16_t data_size = size - sizeof (*res); |
264 | const char *data = (0 < data_size) ? (void *) &res[1] : NULL; | 264 | const char *data = (0 < data_size) ? (void *) &res[1] : NULL; |
265 | GNUNET_CLIENT_MANAGER_op_result (chn->client, GNUNET_ntohll (res->op_id), | 265 | GNUNET_CLIENT_MANAGER_op_result (chn->client, GNUNET_ntohll (res->op_id), |
266 | GNUNET_ntohll_signed (res->result_code), | 266 | GNUNET_ntohll (res->result_code), |
267 | data, data_size); | 267 | data, data_size); |
268 | } | 268 | } |
269 | 269 | ||
@@ -433,7 +433,7 @@ master_recv_start_ack (void *cls, | |||
433 | 433 | ||
434 | struct GNUNET_PSYC_CountersResultMessage * | 434 | struct GNUNET_PSYC_CountersResultMessage * |
435 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; | 435 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; |
436 | int32_t result = GNUNET_ntohl_signed (cres->result_code); | 436 | int32_t result = ntohl (cres->result_code); |
437 | if (GNUNET_OK != result && GNUNET_NO != result) | 437 | if (GNUNET_OK != result && GNUNET_NO != result) |
438 | { | 438 | { |
439 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not start master: %ld\n", result); | 439 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not start master: %ld\n", result); |
@@ -486,7 +486,7 @@ slave_recv_join_ack (void *cls, | |||
486 | sizeof (struct GNUNET_PSYC_Channel)); | 486 | sizeof (struct GNUNET_PSYC_Channel)); |
487 | struct GNUNET_PSYC_CountersResultMessage * | 487 | struct GNUNET_PSYC_CountersResultMessage * |
488 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; | 488 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; |
489 | int32_t result = GNUNET_ntohl_signed (cres->result_code); | 489 | int32_t result = ntohl (cres->result_code); |
490 | if (GNUNET_YES != result && GNUNET_NO != result) | 490 | if (GNUNET_YES != result && GNUNET_NO != result) |
491 | { | 491 | { |
492 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not join slave.\n"); | 492 | LOG (GNUNET_ERROR_TYPE_ERROR, "Could not join slave.\n"); |
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 48621ad83..4211772f1 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -497,7 +497,7 @@ client_send_result (struct GNUNET_SERVER_Client *client, uint64_t op_id, | |||
497 | res = GNUNET_malloc (sizeof (*res) + data_size); | 497 | res = GNUNET_malloc (sizeof (*res) + data_size); |
498 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); | 498 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE); |
499 | res->header.size = htons (sizeof (*res) + data_size); | 499 | res->header.size = htons (sizeof (*res) + data_size); |
500 | res->result_code = GNUNET_htonll_signed (result_code); | 500 | res->result_code = GNUNET_htonll (result_code); |
501 | res->op_id = op_id; | 501 | res->op_id = op_id; |
502 | if (0 < data_size) | 502 | if (0 < data_size) |
503 | memcpy (&res[1], data, data_size); | 503 | memcpy (&res[1], data, data_size); |
@@ -1558,7 +1558,7 @@ psyc_recv_history_message (void *cls, | |||
1558 | res->header.size = htons (sizeof (*res) + size); | 1558 | res->header.size = htons (sizeof (*res) + size); |
1559 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_HISTORY_RESULT); | 1559 | res->header.type = htons (GNUNET_MESSAGE_TYPE_PSYC_HISTORY_RESULT); |
1560 | res->op_id = opcls->op_id; | 1560 | res->op_id = opcls->op_id; |
1561 | res->result_code = GNUNET_htonll_signed (GNUNET_OK); | 1561 | res->result_code = GNUNET_htonll (GNUNET_OK); |
1562 | 1562 | ||
1563 | memcpy (&res[1], msg, size); | 1563 | memcpy (&res[1], msg, size); |
1564 | 1564 | ||
diff --git a/src/social/social_api.c b/src/social/social_api.c index 3c580b0bc..74a13cc35 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -661,7 +661,7 @@ place_recv_result (void *cls, | |||
661 | uint16_t data_size = size - sizeof (*res); | 661 | uint16_t data_size = size - sizeof (*res); |
662 | const char *data = (0 < data_size) ? (const char *) &res[1] : NULL; | 662 | const char *data = (0 < data_size) ? (const char *) &res[1] : NULL; |
663 | GNUNET_CLIENT_MANAGER_op_result (plc->client, GNUNET_ntohll (res->op_id), | 663 | GNUNET_CLIENT_MANAGER_op_result (plc->client, GNUNET_ntohll (res->op_id), |
664 | GNUNET_ntohll_signed (res->result_code), | 664 | GNUNET_ntohll (res->result_code), |
665 | data, data_size); | 665 | data, data_size); |
666 | } | 666 | } |
667 | 667 | ||
diff --git a/src/util/common_endian.c b/src/util/common_endian.c index 81f9a79e8..45707f4ef 100644 --- a/src/util/common_endian.c +++ b/src/util/common_endian.c | |||
@@ -93,47 +93,4 @@ GNUNET_ntoh_double (double d) | |||
93 | } | 93 | } |
94 | 94 | ||
95 | 95 | ||
96 | uint64_t | ||
97 | GNUNET_htonll_signed (int64_t n) | ||
98 | { | ||
99 | return GNUNET_htonll (n - INT64_MIN); | ||
100 | } | ||
101 | |||
102 | |||
103 | int64_t | ||
104 | GNUNET_ntohll_signed (uint64_t n) | ||
105 | { | ||
106 | return GNUNET_ntohll (n) + INT64_MIN; | ||
107 | } | ||
108 | |||
109 | |||
110 | uint32_t | ||
111 | GNUNET_htonl_signed (int32_t n) | ||
112 | { | ||
113 | return htonl (n - INT32_MIN); | ||
114 | } | ||
115 | |||
116 | |||
117 | int32_t | ||
118 | GNUNET_ntohl_signed (uint32_t n) | ||
119 | { | ||
120 | return ntohl (n) + INT32_MIN; | ||
121 | } | ||
122 | |||
123 | |||
124 | uint16_t | ||
125 | GNUNET_htons_signed (int16_t n) | ||
126 | { | ||
127 | return htons (n - INT16_MIN); | ||
128 | } | ||
129 | |||
130 | |||
131 | int16_t | ||
132 | GNUNET_ntohs_signed (uint16_t n) | ||
133 | { | ||
134 | return ntohs (n) + INT16_MIN; | ||
135 | } | ||
136 | |||
137 | |||
138 | |||
139 | /* end of common_endian.c */ | 96 | /* end of common_endian.c */ |