1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
|
From: Ronnie Sahlberg <ronniesahlberg@gmail.com>
Subject: [PATCH] Handle a bunch of other compiler warnings on armv6
Origin: upstream, https://github.com/sahlberg/libsmb2/commit/55555e27e3e9d84503ff276ed7a1fb08c2c35019
Bug: https://github.com/sahlberg/libsmb2/issues/408
Last-Update: 2024-04-03
and similararchectures that can not handle unaligned accesses
and where pointer conversions cause compiler warnings when converting
a pointer to a larger type.
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
---
lib/alloc.c | 2 +-
lib/dcerpc.c | 30 +++++++++++++++---------------
lib/ntlmssp.c | 2 +-
lib/pdu.c | 4 ++--
lib/smb2-cmd-create.c | 2 +-
lib/smb2-cmd-negotiate.c | 2 +-
lib/smb2-cmd-query-directory.c | 8 ++++----
lib/smb2-cmd-tree-connect.c | 2 +-
lib/smb2-data-file-info.c | 4 ++--
lib/smb2-data-filesystem-info.c | 4 ++--
lib/smb2-data-reparse-point.c | 4 ++--
11 files changed, 34 insertions(+), 34 deletions(-)
diff --git a/lib/alloc.c b/lib/alloc.c
index bd5c8aa..03f125b 100644
--- a/lib/alloc.c
+++ b/lib/alloc.c
@@ -68,7 +68,7 @@
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+ (type *)(void *)( (char *)__mptr - offsetof(type,member) );})
struct smb2_alloc_entry {
struct smb2_alloc_entry *next;
diff --git a/lib/dcerpc.c b/lib/dcerpc.c
index 8799ca0..5a31b6e 100644
--- a/lib/dcerpc.c
+++ b/lib/dcerpc.c
@@ -69,7 +69,7 @@
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
+ (type *)(void *)( (char *)__mptr - offsetof(type,member) );})
struct dcerpc_deferred_pointer {
dcerpc_coder coder;
@@ -292,9 +292,9 @@ dcerpc_set_uint16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
return -1;
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- *(uint16_t *)(iov->buf + *offset) = htobe16(value);
+ *(uint16_t *)(void *)(iov->buf + *offset) = htobe16(value);
} else {
- *(uint16_t *)(iov->buf + *offset) = htole16(value);
+ *(uint16_t *)(void *)(iov->buf + *offset) = htole16(value);
}
*offset += 2;
@@ -311,9 +311,9 @@ dcerpc_set_uint32(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
return -1;
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- *(uint32_t *)(iov->buf + *offset) = htobe32(value);
+ *(uint32_t *)(void *)(iov->buf + *offset) = htobe32(value);
} else {
- *(uint32_t *)(iov->buf + *offset) = htole32(value);
+ *(uint32_t *)(void *)(iov->buf + *offset) = htole32(value);
}
*offset += 4;
return 0;
@@ -329,9 +329,9 @@ dcerpc_set_uint64(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
return -1;
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- *(uint64_t *)(iov->buf + *offset) = htobe64(value);
+ *(uint64_t *)(void *)(iov->buf + *offset) = htobe64(value);
} else {
- *(uint64_t *)(iov->buf + *offset) = htole64(value);
+ *(uint64_t *)(void *)(iov->buf + *offset) = htole64(value);
}
*offset += 8;
return 0;
@@ -361,9 +361,9 @@ dcerpc_get_uint16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
return -1;
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- val = be16toh(*(uint16_t *)(iov->buf + *offset));
+ val = be16toh(*(uint16_t *)(void *)(iov->buf + *offset));
} else {
- val = le16toh(*(uint16_t *)(iov->buf + *offset));
+ val = le16toh(*(uint16_t *)(void *)(iov->buf + *offset));
}
*value = val;
*offset += 2;
@@ -383,9 +383,9 @@ dcerpc_get_uint32(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- val = be32toh(*(uint32_t *)(iov->buf + *offset));
+ val = be32toh(*(uint32_t *)(void *)(iov->buf + *offset));
} else {
- val = le32toh(*(uint32_t *)(iov->buf + *offset));
+ val = le32toh(*(uint32_t *)(void *)(iov->buf + *offset));
}
*value = val;
*offset += 4;
@@ -404,9 +404,9 @@ dcerpc_get_uint64(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
return -1;
}
if (!(pdu->hdr.packed_drep[0] & DCERPC_DR_LITTLE_ENDIAN)) {
- val = be64toh(*(uint64_t *)(iov->buf + *offset));
+ val = be64toh(*(uint64_t *)(void *)(iov->buf + *offset));
} else {
- val = le64toh(*(uint64_t *)(iov->buf + *offset));
+ val = le64toh(*(uint64_t *)(void *)(iov->buf + *offset));
}
*value = val;
*offset += 8;
@@ -1053,10 +1053,10 @@ dcerpc_decode_utf16(struct dcerpc_context *ctx, struct dcerpc_pdu *pdu,
if (dcerpc_get_uint16(ctx, pdu, iov, &o, &v)) {
return -1;
}
- *(uint16_t *)&iov->buf[*offset + i * 2] = v;
+ *(uint16_t *)(void *)&iov->buf[*offset + i * 2] = v;
}
}
- tmp = smb2_utf16_to_utf8((uint16_t *)(&iov->buf[*offset]), (size_t)s->actual_count);
+ tmp = smb2_utf16_to_utf8((uint16_t *)(void *)(&iov->buf[*offset]), (size_t)s->actual_count);
*offset += (int)s->actual_count * 2;
str = smb2_alloc_data(ctx->smb2, pdu->payload, strlen(tmp) + 1);
diff --git a/lib/ntlmssp.c b/lib/ntlmssp.c
index d309362..ec015a3 100644
--- a/lib/ntlmssp.c
+++ b/lib/ntlmssp.c
@@ -999,7 +999,7 @@ ntlmssp_get_utf16_field(uint8_t *input_buf, int input_len, int offset, char **re
memcpy(&u32, &input_buf[offset + 4], 4);
field_off = le32toh(u32);
if (field_len && field_off) {
- *result = (char*)smb2_utf16_to_utf8((uint16_t*)(input_buf + field_off), field_len / 2);
+ *result = (char*)smb2_utf16_to_utf8((uint16_t *)(void *)(input_buf + field_off), field_len / 2);
}
}
diff --git a/lib/pdu.c b/lib/pdu.c
index 7144b7f..573dc86 100644
--- a/lib/pdu.c
+++ b/lib/pdu.c
@@ -363,7 +363,7 @@ smb2_set_uint16(struct smb2_iovec *iov, int offset, uint16_t value)
if (offset + sizeof(uint16_t) > iov->len) {
return -1;
}
- *(uint16_t *)(iov->buf + offset) = htole16(value);
+ *(uint16_t *)(void *)(iov->buf + offset) = htole16(value);
return 0;
}
@@ -373,7 +373,7 @@ smb2_set_uint32(struct smb2_iovec *iov, int offset, uint32_t value)
if (offset + sizeof(uint32_t) > iov->len) {
return -1;
}
- *(uint32_t *)(iov->buf + offset) = htole32(value);
+ *(uint32_t *)(void *)(iov->buf + offset) = htole32(value);
return 0;
}
diff --git a/lib/smb2-cmd-create.c b/lib/smb2-cmd-create.c
index 9748634..4991ed8 100644
--- a/lib/smb2-cmd-create.c
+++ b/lib/smb2-cmd-create.c
@@ -450,7 +450,7 @@ smb2_process_create_request_variable(struct smb2_context *smb2,
req->name = NULL;
if (req->name_length > 0) {
- req->name = smb2_utf16_to_utf8((const uint16_t*)iov->buf, req->name_length / 2);
+ req->name = smb2_utf16_to_utf8((const uint16_t *)(void *)iov->buf, req->name_length / 2);
if (req->name) {
name_byte_len = strlen(req->name) + 1;
ptr = smb2_alloc_init(smb2, name_byte_len);
diff --git a/lib/smb2-cmd-negotiate.c b/lib/smb2-cmd-negotiate.c
index e4eeee1..190a227 100644
--- a/lib/smb2-cmd-negotiate.c
+++ b/lib/smb2-cmd-negotiate.c
@@ -531,7 +531,7 @@ smb2_parse_netname_request_context(struct smb2_context *smb2,
char *client;
memcpy(netname, iov->buf + offset, len);
- client = discard_const(smb2_utf16_to_utf8((uint16_t *)netname, len));
+ client = discard_const(smb2_utf16_to_utf8((uint16_t *)(void *)netname, len));
free(client);
return 0;
}
diff --git a/lib/smb2-cmd-query-directory.c b/lib/smb2-cmd-query-directory.c
index 3dbd2f4..31b5002 100644
--- a/lib/smb2-cmd-query-directory.c
+++ b/lib/smb2-cmd-query-directory.c
@@ -82,7 +82,7 @@ smb2_decode_fileidfulldirectoryinformation(
smb2_get_uint32(vec, 64, &fs->ea_size);
smb2_get_uint64(vec, 72, &fs->file_id);
- fs->name = smb2_utf16_to_utf8((uint16_t *)&vec->buf[80], name_len / 2);
+ fs->name = smb2_utf16_to_utf8((uint16_t *)(void *)&vec->buf[80], name_len / 2);
smb2_get_uint64(vec, 8, &t);
smb2_win_to_timeval(t, &fs->creation_time);
@@ -226,7 +226,7 @@ smb2_encode_query_directory_reply(struct smb2_context *smb2,
in_offset = 0;
in_remain = fslen;
do {
- fs = (struct smb2_fileidbothdirectoryinformation*)(rep->output_buffer + in_offset);
+ fs = (struct smb2_fileidbothdirectoryinformation*)(void *)(rep->output_buffer + in_offset);
fname_len = 0;
if (fs->name && fs->name[0]) {
name = smb2_utf8_to_utf16(fs->name);
@@ -290,7 +290,7 @@ smb2_encode_query_directory_reply(struct smb2_context *smb2,
else {
do {
- fs = (struct smb2_fileidbothdirectoryinformation*)(rep->output_buffer + in_offset);
+ fs = (struct smb2_fileidbothdirectoryinformation*)(void *)(rep->output_buffer + in_offset);
fname_len = 0;
if (fs->name && fs->name[0]) {
name = smb2_utf8_to_utf16(fs->name);
@@ -543,7 +543,7 @@ smb2_process_query_directory_request_variable(struct smb2_context *smb2,
int name_byte_len;
if (req->file_name_length > 0) {
- req->name = smb2_utf16_to_utf8((uint16_t*)&iov->buf[IOVREQ_OFFSET], req->file_name_length / 2);
+ req->name = smb2_utf16_to_utf8((uint16_t*)(void *)&iov->buf[IOVREQ_OFFSET], req->file_name_length / 2);
if (req->name) {
name_byte_len = strlen(req->name) + 1;
ptr = smb2_alloc_init(smb2, name_byte_len);
diff --git a/lib/smb2-cmd-tree-connect.c b/lib/smb2-cmd-tree-connect.c
index 15d5b14..a4846a7 100644
--- a/lib/smb2-cmd-tree-connect.c
+++ b/lib/smb2-cmd-tree-connect.c
@@ -260,7 +260,7 @@ smb2_process_tree_connect_request_variable(struct smb2_context *smb2,
struct smb2_tree_connect_request *req = (struct smb2_tree_connect_request*)pdu->payload;
struct smb2_iovec *iov = &smb2->in.iov[smb2->in.niov - 1];
- req->path = (uint16_t*)iov->buf;
+ req->path = (uint16_t*)(void *)iov->buf;
return 0;
}
diff --git a/lib/smb2-data-file-info.c b/lib/smb2-data-file-info.c
index 7b921ff..e12a84e 100644
--- a/lib/smb2-data-file-info.c
+++ b/lib/smb2-data-file-info.c
@@ -199,7 +199,7 @@ smb2_decode_file_all_info(struct smb2_context *smb2,
smb2_get_uint32(vec, 96, &name_len);
if (name_len > 0) {
- name = smb2_utf16_to_utf8((uint16_t *)&vec->buf[100], name_len / 2);
+ name = smb2_utf16_to_utf8((uint16_t *)(void *)&vec->buf[100], name_len / 2);
fs->name = smb2_alloc_data(smb2, memctx, strlen(name) + 1);
if (fs->name == NULL) {
free(discard_const(name));
@@ -249,7 +249,7 @@ smb2_encode_file_all_info(struct smb2_context *smb2,
if (name) {
name_len = 2 * name->len;
smb2_set_uint32(vec, 96, name_len);
- memcpy((uint16_t *)&vec->buf[100], name->val, name_len);
+ memcpy((uint16_t *)(void *)&vec->buf[100], name->val, name_len);
free(name);
return 100 + name_len;
} else {
diff --git a/lib/smb2-data-filesystem-info.c b/lib/smb2-data-filesystem-info.c
index 962437f..1de010a 100644
--- a/lib/smb2-data-filesystem-info.c
+++ b/lib/smb2-data-filesystem-info.c
@@ -68,7 +68,7 @@ smb2_decode_file_fs_volume_info(struct smb2_context *smb2,
smb2_get_uint32(vec, 12, &fs->volume_label_length);
smb2_get_uint8(vec, 16, &fs->supports_objects);
smb2_get_uint8(vec, 17, &fs->reserved);
- name = smb2_utf16_to_utf8((uint16_t *)&vec->buf[18],
+ name = smb2_utf16_to_utf8((uint16_t *)(void *)&vec->buf[18],
fs->volume_label_length / 2);
fs->volume_label = smb2_alloc_data(smb2, memctx, strlen(name) + 1);
if (fs->volume_label == NULL) {
@@ -186,7 +186,7 @@ smb2_decode_file_fs_attribute_info(struct smb2_context *smb2,
smb2_get_uint32(vec, 8, &name_len);
if (name_len > 0) {
- name = smb2_utf16_to_utf8((uint16_t*)&vec->buf[12], name_len / 2);
+ name = smb2_utf16_to_utf8((uint16_t*)(void *)&vec->buf[12], name_len / 2);
if (!name) {
return -1;
diff --git a/lib/smb2-data-reparse-point.c b/lib/smb2-data-reparse-point.c
index b53c711..13e5abf 100644
--- a/lib/smb2-data-reparse-point.c
+++ b/lib/smb2-data-reparse-point.c
@@ -85,7 +85,7 @@ smb2_decode_reparse_data_buffer(struct smb2_context *smb2,
return -1;
}
- tmp = smb2_utf16_to_utf8((uint16_t *)(&vec->buf[suboffset + 20]),
+ tmp = smb2_utf16_to_utf8((uint16_t *)(void *)(&vec->buf[suboffset + 20]),
sublen / 2);
rp->symlink.subname = smb2_alloc_data(smb2, rp,
strlen(tmp) + 1);
@@ -101,7 +101,7 @@ smb2_decode_reparse_data_buffer(struct smb2_context *smb2,
if (printoffset + printlen + 12 > rp->reparse_data_length) {
return -1;
}
- tmp = smb2_utf16_to_utf8((uint16_t *)(&vec->buf[printoffset + 20]),
+ tmp = smb2_utf16_to_utf8((uint16_t *)(void *)(&vec->buf[printoffset + 20]),
printlen / 2);
rp->symlink.printname = smb2_alloc_data(smb2, rp,
strlen(tmp) + 1);
--
2.47.2
|