Commit 1ea70841f07666af69e481d4ffdd6edb56db3c92

Authored by Jiri Slaby
Committed by David S. Miller
1 parent 08cb3f60b2

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>

Showing 1 changed file with 9 additions and 9 deletions Side-by-side Diff

drivers/isdn/hardware/eicon/message.c
... ... @@ -2692,7 +2692,7 @@
2692 2692 if (!(fax_control_bits & T30_CONTROL_BIT_MORE_DOCUMENTS)
2693 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 2696 fax_info_change = false;
2697 2697 if (ncpi->length >= 4)
2698 2698 {
... ... @@ -2754,7 +2754,7 @@
2754 2754 for (i = 0; i < w; i++)
2755 2755 ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id[i] = fax_parms[4].info[1+i];
2756 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 2758 w = fax_parms[5].length;
2759 2759 if (w > 20)
2760 2760 w = 20;
... ... @@ -2788,7 +2788,7 @@
2788 2788 }
2789 2789 else
2790 2790 {
2791   - len = (byte)(&(((T30_INFO *) 0)->universal_6));
  2791 + len = offsetof(T30_INFO, universal_6);
2792 2792 }
2793 2793 fax_info_change = true;
2794 2794  
... ... @@ -2892,7 +2892,7 @@
2892 2892 && (plci->nsf_control_bits & T30_NSF_CONTROL_BIT_ENABLE_NSF)
2893 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 2896 if (plci->fax_connect_info_length < len)
2897 2897 {
2898 2898 ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0;
... ... @@ -3802,7 +3802,7 @@
3802 3802 break;
3803 3803 }
3804 3804 ncpi = &m_parms[1];
3805   - len = ((byte)(((T30_INFO *) 0)->station_id + 20));
  3805 + len = offsetof(T30_INFO, station_id) + 20;
3806 3806 if (plci->fax_connect_info_length < len)
3807 3807 {
3808 3808 ((T30_INFO *)(plci->fax_connect_info_buffer))->station_id_len = 0;
... ... @@ -6844,7 +6844,7 @@
6844 6844 if ((plci->requested_options_conn | plci->requested_options | a->requested_options_table[plci->appl->Id-1])
6845 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 6848 while (i < plci->NL.RBuffer->length)
6849 6849 plci->ncpi_buffer[++len] = plci->NL.RBuffer->P[i++];
6850 6850 }
... ... @@ -7236,7 +7236,7 @@
7236 7236 {
7237 7237 plci->RData[1].P = plci->RData[0].P;
7238 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 7240 if ((plci->NL.RBuffer->P[0] & V120_HEADER_EXTEND_BIT) || (plci->NL.RLength == 1))
7241 7241 plci->RData[0].PLength = 1;
7242 7242 else
... ... @@ -8473,7 +8473,7 @@
8473 8473 fax_control_bits |= T30_CONTROL_BIT_ACCEPT_SEL_POLLING;
8474 8474 }
8475 8475 len = nlc[0];
8476   - pos = ((byte)(((T30_INFO *) 0)->station_id + 20));
  8476 + pos = offsetof(T30_INFO, station_id) + 20;
8477 8477 if (pos < plci->fax_connect_info_length)
8478 8478 {
8479 8479 for (i = 1 + plci->fax_connect_info_buffer[pos]; i != 0; i--)
... ... @@ -8525,7 +8525,7 @@
8525 8525 }
8526 8526  
8527 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 8529 for (i = 0; i < len; i++)
8530 8530 plci->fax_connect_info_buffer[i] = nlc[1+i];
8531 8531 ((T30_INFO *) plci->fax_connect_info_buffer)->head_line_len = 0;