Skip to content

Commit 3318e26

Browse files
committed
Refactor _ipp_request_t to avoid issues on embedded platforms with newer C compilers.
1 parent 45bc6c2 commit 3318e26

19 files changed

Lines changed: 155 additions & 189 deletions

File tree

backend/ipp.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2845,9 +2845,9 @@ new_request(
28452845
ippSetVersion(request, version / 10, version % 10);
28462846

28472847
fprintf(stderr, "DEBUG: %s IPP/%d.%d\n",
2848-
ippOpString(request->request.op.operation_id),
2849-
request->request.op.version[0],
2850-
request->request.op.version[1]);
2848+
ippOpString(request->request.op_status),
2849+
request->request.version[0],
2850+
request->request.version[1]);
28512851

28522852
/*
28532853
* Add standard attributes...

berkeley/lpq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ show_jobs(const char *command, /* I - Command name */
404404

405405
if ((response = cupsDoRequest(http, request, "/")) != NULL)
406406
{
407-
if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
407+
if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
408408
{
409409
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
410410
ippDelete(response);
@@ -595,7 +595,7 @@ show_printer(const char *command, /* I - Command name */
595595

596596
if ((response = cupsDoRequest(http, request, "/")) != NULL)
597597
{
598-
if (response->request.status.status_code > IPP_STATUS_OK_CONFLICTING)
598+
if (cupsGetError() > IPP_STATUS_OK_CONFLICTING)
599599
{
600600
_cupsLangPrintf(stderr, "%s: %s", command, cupsGetErrorString());
601601
ippDelete(response);

cups/getdevices.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,9 @@ cupsGetDevices(
246246

247247
attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
248248

249-
DEBUG_printf("cupsGetDevices: status-code=%s, status-message=\"%s\"", ippErrorString(response->request.status.status_code), attr ? attr->values[0].string.text : "");
249+
DEBUG_printf("cupsGetDevices: status-code=%s, status-message=\"%s\"", ippErrorString(response->request.op_status), attr ? attr->values[0].string.text : "");
250250

251-
_cupsSetError(response->request.status.status_code,
252-
attr ? attr->values[0].string.text : ippErrorString(response->request.status.status_code), 0);
251+
_cupsSetError(response->request.op_status, attr ? attr->values[0].string.text : ippErrorString(response->request.op_status), 0);
253252

254253
ippDelete(response);
255254

cups/ipp-private.h

Lines changed: 4 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,11 @@ extern "C" {
3030
// Structures...
3131
//
3232

33-
typedef union _ipp_request_u // Request Header
33+
typedef struct _ipp_request_s // Message Header
3434
{
35-
struct // Any Header
36-
{
37-
ipp_uchar_t version[2]; // Protocol version number
38-
int op_status; // Operation ID or status code
39-
int request_id; // Request ID
40-
} any;
41-
42-
struct // Operation Header
43-
{
44-
ipp_uchar_t version[2]; // Protocol version number
45-
ipp_op_t operation_id; // Operation ID
46-
int request_id; // Request ID
47-
} op;
48-
49-
struct // Status Header
50-
{
51-
ipp_uchar_t version[2]; // Protocol version number
52-
ipp_status_t status_code; // Status code
53-
int request_id; // Request ID
54-
} status;
55-
56-
struct // Event Header
57-
{
58-
ipp_uchar_t version[2]; // Protocol version number
59-
ipp_status_t status_code; // Status code
60-
int request_id; // Request ID
61-
} event;
35+
ipp_uchar_t version[2]; // Protocol version number
36+
short op_status; // Operation ID or status code
37+
int request_id; // Request ID
6238
} _ipp_request_t;
6339

6440
typedef union _ipp_value_u // Attribute Value

cups/ipp.c

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2241,7 +2241,7 @@ ippGetOperation(ipp_t *ipp) // I - IPP request message
22412241
return ((ipp_op_t)0);
22422242

22432243
// Return the value...
2244-
return (ipp->request.op.operation_id);
2244+
return ((ipp_op_t)ipp->request.op_status);
22452245
}
22462246

22472247

@@ -2290,7 +2290,7 @@ ippGetRequestId(ipp_t *ipp) // I - IPP message
22902290
return (0);
22912291

22922292
// Return the request ID...
2293-
return (ipp->request.any.request_id);
2293+
return (ipp->request.request_id);
22942294
}
22952295

22962296

@@ -2365,7 +2365,7 @@ ippGetStatusCode(ipp_t *ipp) // I - IPP response or event message
23652365
return (IPP_STATUS_ERROR_INTERNAL);
23662366

23672367
// Return the value...
2368-
return (ipp->request.status.status_code);
2368+
return ((ipp_status_t)ipp->request.op_status);
23692369
}
23702370

23712371

@@ -2439,9 +2439,9 @@ ippGetVersion(ipp_t *ipp, // I - IPP message
24392439

24402440
// Return the value...
24412441
if (minor)
2442-
*minor = ipp->request.any.version[1];
2442+
*minor = ipp->request.version[1];
24432443

2444-
return (ipp->request.any.version[0]);
2444+
return (ipp->request.version[0]);
24452445
}
24462446

24472447

@@ -2493,10 +2493,10 @@ ippNew(void)
24932493
if (!cg->client_conf_loaded)
24942494
_cupsSetDefaults();
24952495

2496-
temp->request.any.version[0] = (ipp_uchar_t)(cg->server_version / 10);
2497-
temp->request.any.version[1] = (ipp_uchar_t)(cg->server_version % 10);
2498-
temp->use = 1;
2499-
temp->find = temp->fstack;
2496+
temp->request.version[0] = (ipp_uchar_t)(cg->server_version / 10);
2497+
temp->request.version[1] = (ipp_uchar_t)(cg->server_version % 10);
2498+
temp->use = 1;
2499+
temp->find = temp->fstack;
25002500
}
25012501

25022502
DEBUG_printf("1ippNew: Returning %p", (void *)temp);
@@ -2534,8 +2534,8 @@ ippNewRequest(ipp_op_t op) // I - Operation code
25342534
// Set the operation and request ID...
25352535
cupsMutexLock(&request_mutex);
25362536

2537-
request->request.op.operation_id = op;
2538-
request->request.op.request_id = ++request_id;
2537+
request->request.op_status = (short)op;
2538+
request->request.request_id = ++request_id;
25392539

25402540
cupsMutexUnlock(&request_mutex);
25412541

@@ -2581,9 +2581,9 @@ ippNewResponse(ipp_t *request) // I - IPP request message
25812581
return (NULL);
25822582

25832583
// Copy the request values over to the response...
2584-
response->request.status.version[0] = request->request.op.version[0];
2585-
response->request.status.version[1] = request->request.op.version[1];
2586-
response->request.status.request_id = request->request.op.request_id;
2584+
response->request.version[0] = request->request.version[0];
2585+
response->request.version[1] = request->request.version[1];
2586+
response->request.request_id = request->request.request_id;
25872587

25882588
// The first attribute MUST be attributes-charset...
25892589
attr = request->attrs;
@@ -3035,7 +3035,7 @@ ippSetOperation(ipp_t *ipp, // I - IPP request message
30353035
return (0);
30363036

30373037
// Set the operation and return...
3038-
ipp->request.op.operation_id = op;
3038+
ipp->request.op_status = (short)op;
30393039

30403040
return (1);
30413041
}
@@ -3103,7 +3103,7 @@ ippSetRequestId(ipp_t *ipp, // I - IPP message
31033103
return (0);
31043104

31053105
// Set the request ID and return...
3106-
ipp->request.any.request_id = request_id;
3106+
ipp->request.request_id = request_id;
31073107

31083108
return (1);
31093109
}
@@ -3192,7 +3192,7 @@ ippSetStatusCode(ipp_t *ipp, // I - IPP response or event message
31923192
return (0);
31933193

31943194
// Set the status code and return...
3195-
ipp->request.status.status_code = status;
3195+
ipp->request.op_status = (short)status;
31963196

31973197
return (1);
31983198
}
@@ -3590,8 +3590,8 @@ ippSetVersion(ipp_t *ipp, // I - IPP message
35903590
return (0);
35913591

35923592
// Set the version number...
3593-
ipp->request.any.version[0] = (ipp_uchar_t)major;
3594-
ipp->request.any.version[1] = (ipp_uchar_t)minor;
3593+
ipp->request.version[0] = (ipp_uchar_t)major;
3594+
ipp->request.version[1] = (ipp_uchar_t)minor;
35953595

35963596
return (1);
35973597
}
@@ -4258,18 +4258,18 @@ ippWriteIO(void *dst, // I - Destination
42584258
// Total = 8 bytes
42594259
bufptr = buffer;
42604260

4261-
*bufptr++ = ipp->request.any.version[0];
4262-
*bufptr++ = ipp->request.any.version[1];
4263-
*bufptr++ = (ipp_uchar_t)(ipp->request.any.op_status >> 8);
4264-
*bufptr++ = (ipp_uchar_t)ipp->request.any.op_status;
4265-
*bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 24);
4266-
*bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 16);
4267-
*bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 8);
4268-
*bufptr++ = (ipp_uchar_t)ipp->request.any.request_id;
4261+
*bufptr++ = ipp->request.version[0];
4262+
*bufptr++ = ipp->request.version[1];
4263+
*bufptr++ = (ipp_uchar_t)(ipp->request.op_status >> 8);
4264+
*bufptr++ = (ipp_uchar_t)ipp->request.op_status;
4265+
*bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 24);
4266+
*bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 16);
4267+
*bufptr++ = (ipp_uchar_t)(ipp->request.request_id >> 8);
4268+
*bufptr++ = (ipp_uchar_t)ipp->request.request_id;
42694269

42704270
DEBUG_printf("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]);
4271-
DEBUG_printf("2ippWriteIO: op_status=%04x", ipp->request.any.op_status);
4272-
DEBUG_printf("2ippWriteIO: request_id=%d", ipp->request.any.request_id);
4271+
DEBUG_printf("2ippWriteIO: op_status=%04x", ipp->request.op_status);
4272+
DEBUG_printf("2ippWriteIO: request_id=%d", ipp->request.request_id);
42734273

42744274
if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
42754275
{
@@ -5431,14 +5431,14 @@ ipp_read_io(void *src, // I - Data source
54315431
}
54325432

54335433
// Then copy the request header over...
5434-
ipp->request.any.version[0] = buffer[0];
5435-
ipp->request.any.version[1] = buffer[1];
5436-
ipp->request.any.op_status = (buffer[2] << 8) | buffer[3];
5437-
ipp->request.any.request_id = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
5434+
ipp->request.version[0] = buffer[0];
5435+
ipp->request.version[1] = buffer[1];
5436+
ipp->request.op_status = (short)((buffer[2] << 8) | buffer[3]);
5437+
ipp->request.request_id = (buffer[4] << 24) | (buffer[5] << 16) | (buffer[6] << 8) | buffer[7];
54385438

54395439
DEBUG_printf("2ipp_read_io: version=%d.%d", buffer[0], buffer[1]);
5440-
DEBUG_printf("2ipp_read_io: op_status=%04x", ipp->request.any.op_status);
5441-
DEBUG_printf("2ipp_read_io: request_id=%d", ipp->request.any.request_id);
5440+
DEBUG_printf("2ipp_read_io: op_status=%04x", ipp->request.op_status);
5441+
DEBUG_printf("2ipp_read_io: request_id=%d", ipp->request.request_id);
54425442
}
54435443

54445444
ipp->state = IPP_STATE_ATTRIBUTE;

cups/request.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* IPP utilities for CUPS.
33
*
4-
* Copyright © 2020-2025 by OpenPrinting.
4+
* Copyright © 2020-2026 by OpenPrinting.
55
* Copyright © 2007-2018 by Apple Inc.
66
* Copyright © 1997-2007 by Easy Software Products.
77
*
@@ -46,7 +46,7 @@ cupsDoFileRequest(http_t *http, /* I - Connection to server or @code CUPS_HT
4646
int infile; /* Input file */
4747

4848

49-
DEBUG_printf("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", filename=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, filename);
49+
DEBUG_printf("cupsDoFileRequest(http=%p, request=%p(%s), resource=\"%s\", filename=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op_status) : "?", resource, filename);
5050

5151
if (filename)
5252
{
@@ -112,7 +112,7 @@ cupsDoIORequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
112112
char buffer[32768]; /* Output buffer */
113113

114114

115-
DEBUG_printf("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", infile=%d, outfile=%d)", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, infile, outfile);
115+
DEBUG_printf("cupsDoIORequest(http=%p, request=%p(%s), resource=\"%s\", infile=%d, outfile=%d)", (void *)http, (void *)request, request ? ippOpString(request->request.op_status) : "?", resource, infile, outfile);
116116

117117
/*
118118
* Range check input...
@@ -291,7 +291,7 @@ cupsDoRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP_
291291
ipp_t *request, /* I - IPP request */
292292
const char *resource) /* I - HTTP resource for POST */
293293
{
294-
DEBUG_printf("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource);
294+
DEBUG_printf("cupsDoRequest(http=%p, request=%p(%s), resource=\"%s\")", (void *)http, (void *)request, request ? ippOpString(request->request.op_status) : "?", resource);
295295

296296
return (cupsDoIORequest(http, request, resource, -1, -1));
297297
}
@@ -480,11 +480,9 @@ cupsGetResponse(http_t *http, /* I - Connection to server or @code CUPS_HTTP
480480

481481
attr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT);
482482

483-
DEBUG_printf("1cupsGetResponse: status-code=%s, status-message=\"%s\"", ippErrorString(response->request.status.status_code), attr ? attr->values[0].string.text : "");
483+
DEBUG_printf("1cupsGetResponse: status-code=%s, status-message=\"%s\"", ippErrorString(response->request.op_status), attr ? attr->values[0].string.text : "");
484484

485-
_cupsSetError(response->request.status.status_code,
486-
attr ? attr->values[0].string.text :
487-
ippErrorString(response->request.status.status_code), 0);
485+
_cupsSetError(response->request.op_status, attr ? attr->values[0].string.text : ippErrorString(response->request.op_status), 0);
488486
}
489487

490488
return (response);
@@ -621,7 +619,7 @@ cupsSendRequest(http_t *http, /* I - Connection to server or @code CUPS_HTTP
621619
int digest; /* Are we using Digest authentication? */
622620

623621

624-
DEBUG_printf("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", length=" CUPS_LLFMT ")", (void *)http, (void *)request, request ? ippOpString(request->request.op.operation_id) : "?", resource, CUPS_LLCAST length);
622+
DEBUG_printf("cupsSendRequest(http=%p, request=%p(%s), resource=\"%s\", length=" CUPS_LLFMT ")", (void *)http, (void *)request, request ? ippOpString(request->request.op_status) : "?", resource, CUPS_LLCAST length);
625623

626624
/*
627625
* Range check input...

cups/testipp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ main(int argc, // I - Number of command-line arguments
327327
testBegin("Create Sample Request");
328328

329329
request = ippNew();
330-
request->request.op.version[0] = 0x01;
331-
request->request.op.version[1] = 0x01;
332-
request->request.op.operation_id = IPP_OP_PRINT_JOB;
333-
request->request.op.request_id = 1;
330+
request->request.version[0] = 0x01;
331+
request->request.version[1] = 0x01;
332+
request->request.op_status = IPP_OP_PRINT_JOB;
333+
request->request.request_id = 1;
334334

335335
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_CHARSET,
336336
"attributes-charset", NULL, "utf-8");

scheduler/client.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,10 +1709,10 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
17091709
else
17101710
{
17111711
cupsdLogClient(con, CUPSD_LOG_DEBUG, "%d.%d %s %d",
1712-
con->request->request.op.version[0],
1713-
con->request->request.op.version[1],
1714-
ippOpString(con->request->request.op.operation_id),
1715-
con->request->request.op.request_id);
1712+
con->request->request.version[0],
1713+
con->request->request.version[1],
1714+
ippOpString(con->request->request.op_status),
1715+
con->request->request.request_id);
17161716
con->bytes += (off_t)ippGetLength(con->request);
17171717
}
17181718
}

0 commit comments

Comments
 (0)