diff options
author | Jiri Slaby <jirislaby@gmail.com> | 2009-11-04 11:28:12 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-04 11:28:12 -0500 |
commit | 1ea70841f07666af69e481d4ffdd6edb56db3c92 (patch) | |
tree | 13ce5927c8c752a279e811ec68d504246a33835e /drivers/isdn/hardware | |
parent | 08cb3f60b2f866c906a5a779444b30ba8f9a93c8 (diff) |
isdn: eicon: Use offsetof
Use offsetof instead of explicit implementation.
* fixes bug with omitted & like:
len = (byte)(((T30_INFO *) 0)->station_id + 20)
* avoids compiler warnings with wrong sizes (pointer-to-char cast):
len = (byte)(&(((T30_INFO *) 0)->universal_6));
* cleans up the code
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
Cc: Karsten Keil <isdn@linux-pingi.de>
Acked-by: Armin Schindler <armin@melware.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/isdn/hardware')
-rw-r--r-- | drivers/isdn/hardware/eicon/message.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/isdn/hardware/eicon/message.c b/drivers/isdn/hardware/eicon/message.c index 27d5dd68f4fb..ae89fb89da64 100644 --- a/drivers/isdn/hardware/eicon/message.c +++ b/drivers/isdn/hardware/eicon/message.c | |||
@@ -2692,7 +2692,7 @@ static byte connect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, | |||
2692 | if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS) | 2692 | if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS) |
2693 | || (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)) | 2693 | || (fax_feature_bits & T30_FEATURE_BIT_MORE_DOCUMENTS)) |
2694 | { | 2694 | { |
2695 | len = (byte)(&(((T30_INFO *) 0)->universal_6)); | 2695 | len = offsetof(T30_INFO, universal_6); |
2696 | fax_info_change = false; | 2696 | fax_info_change = false; |
2697 | if (ncpi->length >= 4) | 2697 | if (ncpi->length >= 4) |
2698 | { | 2698 | { |
@@ -2754,7 +2754,7 @@ static byte connect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, | |||
2754 | for (i = 0; i < w; i++) | 2754 | for (i = 0; i < w; i++) |
2755 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1+i]; | 2755 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1+i]; |
2756 | ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; | 2756 | ((T30_INFO *)(plci->fax_connect_info_buffer))->head_line_len = 0; |
2757 | len = (byte)(((T30_INFO *) 0)->station_id + 20); | 2757 | len = offsetof(T30_INFO, station_id) + 20; |
2758 | w = fax_parms[5].length; | 2758 | w = fax_parms[5].length; |
2759 | if (w > 20) | 2759 | if (w > 20) |
2760 | w = 20; | 2760 | w = 20; |
@@ -2788,7 +2788,7 @@ static byte connect_b3_req(dword Id, word Number, DIVA_CAPI_ADAPTER *a, | |||
2788 | } | 2788 | } |
2789 | else | 2789 | else |
2790 | { | 2790 | { |
2791 | len = (byte)(&(((T30_INFO *) 0)->universal_6)); | 2791 | len = offsetof(T30_INFO, universal_6); |
2792 | } | 2792 | } |
2793 | fax_info_change = true; | 2793 | fax_info_change = true; |
2794 | 2794 | ||
@@ -2892,7 +2892,7 @@ static byte connect_b3_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, | |||
2892 | && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) | 2892 | && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF) |
2893 | && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) | 2893 | && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_NEGOTIATE_RESP)) |
2894 | { | 2894 | { |
2895 | len = ((byte)(((T30_INFO *) 0)->station_id + 20)); | 2895 | len = offsetof(T30_INFO, station_id) + 20; |
2896 | if (plci->fax_connect_info_length < len) | 2896 | if (plci->fax_connect_info_length < len) |
2897 | { | 2897 | { |
2898 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; | 2898 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; |
@@ -3802,7 +3802,7 @@ static byte manufacturer_res(dword Id, word Number, DIVA_CAPI_ADAPTER *a, | |||
3802 | break; | 3802 | break; |
3803 | } | 3803 | } |
3804 | ncpi = &m_parms[1]; | 3804 | ncpi = &m_parms[1]; |
3805 | len = ((byte)(((T30_INFO *) 0)->station_id + 20)); | 3805 | len = offsetof(T30_INFO, station_id) + 20; |
3806 | if (plci->fax_connect_info_length < len) | 3806 | if (plci->fax_connect_info_length < len) |
3807 | { | 3807 | { |
3808 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; | 3808 | ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0; |
@@ -6844,7 +6844,7 @@ static void nl_ind(PLCI *plci) | |||
6844 | if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) | 6844 | if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1]) |
6845 | & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) | 6845 | & ((1L << PRIVATE_FAX_SUB_SEP_PWD) | (1L << PRIVATE_FAX_NONSTANDARD))) |
6846 | { | 6846 | { |
6847 | i = ((word)(((T30_INFO *) 0)->station_id + 20)) + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; | 6847 | i = offsetof(T30_INFO, station_id) + 20 + ((T30_INFO *)plci->NL.RBuffer->P)->head_line_len; |
6848 | while (i < plci->NL.RBuffer->length) | 6848 | while (i < plci->NL.RBuffer->length) |
6849 | plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++]; | 6849 | plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++]; |
6850 | } | 6850 | } |
@@ -7236,7 +7236,7 @@ static void nl_ind(PLCI *plci) | |||
7236 | { | 7236 | { |
7237 | plci->RData[1].P = plci->RData[0].P; | 7237 | plci->RData[1].P = plci->RData[0].P; |
7238 | plci->RData[1].PLength = plci->RData[0].PLength; | 7238 | plci->RData[1].PLength = plci->RData[0].PLength; |
7239 | plci->RData[0].P = v120_header_buffer + (-((int) v120_header_buffer) & 3); | 7239 | plci->RData[0].P = v120_header_buffer + (-((unsigned long)v120_header_buffer) & 3); |
7240 | if ((plci->NL.RBuffer->P[0] & V120_HEADER_EXTEND_BIT) || (plci->NL.RLength == 1)) | 7240 | if ((plci->NL.RBuffer->P[0] & V120_HEADER_EXTEND_BIT) || (plci->NL.RLength == 1)) |
7241 | plci->RData[0].PLength = 1; | 7241 | plci->RData[0].PLength = 1; |
7242 | else | 7242 | else |
@@ -8473,7 +8473,7 @@ static word add_b23(PLCI *plci, API_PARSE *bp) | |||
8473 | fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; | 8473 | fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING; |
8474 | } | 8474 | } |
8475 | len = nlc[0]; | 8475 | len = nlc[0]; |
8476 | pos = ((byte)(((T30_INFO *) 0)->station_id + 20)); | 8476 | pos = offsetof(T30_INFO, station_id) + 20; |
8477 | if (pos < plci->fax_connect_info_length) | 8477 | if (pos < plci->fax_connect_info_length) |
8478 | { | 8478 | { |
8479 | for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) | 8479 | for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--) |
@@ -8525,7 +8525,7 @@ static word add_b23(PLCI *plci, API_PARSE *bp) | |||
8525 | } | 8525 | } |
8526 | 8526 | ||
8527 | PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits); | 8527 | PUT_WORD(&(((T30_INFO *)&nlc[1])->control_bits_low), fax_control_bits); |
8528 | len = ((byte)(((T30_INFO *) 0)->station_id + 20)); | 8528 | len = offsetof(T30_INFO, station_id) + 20; |
8529 | for (i = 0; i < len; i++) | 8529 | for (i = 0; i < len; i++) |
8530 | plci->fax_connect_info_buffer[i] = nlc[1+i]; | 8530 | plci->fax_connect_info_buffer[i] = nlc[1+i]; |
8531 | ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0; | 8531 | ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0; |