Skip to contentSkip to conversation

Add types, and some fixes

PATCH Applied Alejandro Colomar 2 participants 28 messages Sep 25, 2020 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

cover Add types, and some fixes

Hello Michael,

The .RS/.RE Branden and you talked about
in a previous email was useful here :-)

Cheers,

Alex

Alejandro Colomar (10):
system_data_types.7: ffix
system_data_types.7: Add lconv
lconv.3: New link to system_data_types(7) system_data_types.7: Add float_t
float_t.3: New link to system_data_types(7) system_data_types.7: Add double_t
double_t.3: New link to system_data_types(7) seccomp.2: Remove unneeded cast
seccomp.2: Use ARRAY_SIZE() macro instead of raw sizeof division getgrent_r.3: Declare variables with different types in different
lines

 man2/seccomp.2           |   3 +-
 man3/double_t.3          |   1 +
 man3/float_t.3           |   1 +
 man3/getgrent_r.3        |   3 +-
 man3/lconv.3             |   1 +
 man7/system_data_types.7 | 121 ++++++++++++++++++++++++++++++++++++++-
 6 files changed, 127 insertions(+), 3 deletions(-)
 create mode 100644 man3/double_t.3
 create mode 100644 man3/float_t.3
 create mode 100644 man3/lconv.3
Signature · 1 line
2.28.0
#1 lore raw

PATCH 1/10 system_data_types.7: ffix

---
 man7/system_data_types.7 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man7/system_data_types.7 +1 -1
index f40b1373f..095a20f6d 100644
@@ -219,7 +219,7 @@ typedef struct {
 .EE
 .IP
 It is the type of the value returned by the
-.I imaxdiv (3)
+.BR imaxdiv (3)
 function.
 .IP
 Conforming to: C99 and later; POSIX.1-2001 and later.
Signature · 1 line
2.28.0
#2 lore raw

Re: [PATCH 01/10] system_data_types.7: ffix

Quoted 1 line · Alejandro Colomar

Thanks, Alex. Patch applied.

Cheers,

Michael

Quoted 18 lines
---
 man7/system_data_types.7 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man7/system_data_types.7 +1 -1
index f40b1373f..095a20f6d 100644
@@ -219,7 +219,7 @@ typedef struct {
 .EE
 .IP
 It is the type of the value returned by the
-.I imaxdiv (3)
+.BR imaxdiv (3)
 function.
 .IP
 Conforming to: C99 and later; POSIX.1-2001 and later.
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#3 lore raw

PATCH 2/10 system_data_types.7: Add lconv

In reply to Alejandro Colomar
---
 man7/system_data_types.7 | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
man7/system_data_types.7 +47 -0
index 095a20f6d..b04457bbf 100644
@@ -226,6 +226,53 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR imaxdiv (3)
+.\"------------------------------------- lconv ------------------------/
+.TP
+.I lconv
+.IP
+Include:
+.IR <locale.h> .
+.IP
+.EX
+struct lconv {                  /* Values in the "C" locale: */
+    char   *decimal_point;      /* "." */
+    char   *thousands_sep;      /* "" */
+    char   *grouping;           /* "" */
+    char   *mon_decimal_point;  /* "" */
+    char   *mon_thousands_sep;  /* "" */
+    char   *mon_grouping;       /* "" */
+    char   *positive_sign;      /* "" */
+    char   *negative_sign;      /* "" */
+    char   *currency_symbol;    /* "" */
+    char    frac_digits;        /* CHAR_MAX */
+    char    p_cs_precedes;      /* CHAR_MAX */
+    char    n_cs_precedes;      /* CHAR_MAX */
+    char    p_sep_by_space;     /* CHAR_MAX */
+    char    n_sep_by_space;     /* CHAR_MAX */
+    char    p_sign_posn;        /* CHAR_MAX */
+    char    n_sign_posn;        /* CHAR_MAX */
+    char   *int_curr_symbol;    /* "" */
+    char    int_frac_digits;    /* CHAR_MAX */
+    char    int_p_cs_precedes;  /* CHAR_MAX */
+    char    int_n_cs_precedes;  /* CHAR_MAX */
+    char    int_p_sep_by_space; /* CHAR_MAX */
+    char    int_n_sep_by_space; /* CHAR_MAX */
+    char    int_p_sign_posn;    /* CHAR_MAX */
+    char    int_n_sign_posn;    /* CHAR_MAX */
+};
+.EE
+.IP
+Contains members related to the formatting of numeric values.
+In the "C" locale, its members have the values
+shown in the comments above.
+.IP
+Conforming to: C11 and later; POSIX.1-2001 and later.
+.IP
+See also:
+.BR setlocale (3),
+.BR localeconv (3),
+.BR charsets (5),
+.BR locale (7)
 .\"------------------------------------- ldiv_t -----------------------/
 .TP
 .I ldiv_t
Signature · 1 line
2.28.0
#4 lore raw

Re: [PATCH 02/10] system_data_types.7: Add lconv

Quoted 1 line · Alejandro Colomar

Patch applied. Thanks, Alex.

Cheers,

Michael

Quoted 63 lines
---
 man7/system_data_types.7 | 47 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 47 insertions(+)
man7/system_data_types.7 +47 -0
index 095a20f6d..b04457bbf 100644
@@ -226,6 +226,53 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR imaxdiv (3)
+.\"------------------------------------- lconv ------------------------/
+.TP
+.I lconv
+.IP
+Include:
+.IR <locale.h> .
+.IP
+.EX
+struct lconv {                  /* Values in the "C" locale: */
+    char   *decimal_point;      /* "." */
+    char   *thousands_sep;      /* "" */
+    char   *grouping;           /* "" */
+    char   *mon_decimal_point;  /* "" */
+    char   *mon_thousands_sep;  /* "" */
+    char   *mon_grouping;       /* "" */
+    char   *positive_sign;      /* "" */
+    char   *negative_sign;      /* "" */
+    char   *currency_symbol;    /* "" */
+    char    frac_digits;        /* CHAR_MAX */
+    char    p_cs_precedes;      /* CHAR_MAX */
+    char    n_cs_precedes;      /* CHAR_MAX */
+    char    p_sep_by_space;     /* CHAR_MAX */
+    char    n_sep_by_space;     /* CHAR_MAX */
+    char    p_sign_posn;        /* CHAR_MAX */
+    char    n_sign_posn;        /* CHAR_MAX */
+    char   *int_curr_symbol;    /* "" */
+    char    int_frac_digits;    /* CHAR_MAX */
+    char    int_p_cs_precedes;  /* CHAR_MAX */
+    char    int_n_cs_precedes;  /* CHAR_MAX */
+    char    int_p_sep_by_space; /* CHAR_MAX */
+    char    int_n_sep_by_space; /* CHAR_MAX */
+    char    int_p_sign_posn;    /* CHAR_MAX */
+    char    int_n_sign_posn;    /* CHAR_MAX */
+};
+.EE
+.IP
+Contains members related to the formatting of numeric values.
+In the "C" locale, its members have the values
+shown in the comments above.
+.IP
+Conforming to: C11 and later; POSIX.1-2001 and later.
+.IP
+See also:
+.BR setlocale (3),
+.BR localeconv (3),
+.BR charsets (5),
+.BR locale (7)
 .\"------------------------------------- ldiv_t -----------------------/
 .TP
 .I ldiv_t
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#6 lore raw

Re: [PATCH 03/10] lconv.3: New link to system_data_types(7)

Quoted 1 line · Alejandro Colomar

Thanks, Alex. Patch applied.

Cheers,

Michael

Quoted 13 lines
---
 man3/lconv.3 | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 man3/lconv.3
man3/lconv.3 new file +1 -0
new file mode 100644
index 000000000..db50c0f09
@@ -0,0 +1 @@
+.so man7/system_data_types.7
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#7 lore raw

PATCH 4/10 system_data_types.7: Add float_t

In reply to Alejandro Colomar
---
 man7/system_data_types.7 | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
man7/system_data_types.7 +36 -0
index b04457bbf..238b9593b 100644
@@ -147,6 +147,42 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR fenv (3)
+.\"------------------------------------- float_t ----------------------/
+.TP
+.I float_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR float .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I float_t
+is
+.IR float .
+.IP *
+1;
+.I float_t
+is
+.IR double .
+.IP *
+2;
+.I float_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I double_t
+type in this page.
 .\"------------------------------------- gid_t ------------------------/
 .TP
 .I gid_t
Signature · 1 line
2.28.0
#8 lore raw

Re: [PATCH 04/10] system_data_types.7: Add float_t

Hi Alex,

A few comments here that also apply for the double_t patch. Could you revise please?

Quoted 12 lines · Alejandro Colomar
---
 man7/system_data_types.7 | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
man7/system_data_types.7 +0 -0
index b04457bbf..238b9593b 100644
@@ -147,6 +147,42 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 158

Quoted 10 lines
man7/system_data_types.7 +9 -0
 .BR fenv (3)
+.\"------------------------------------- float_t ----------------------/
+.TP
+.I float_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR float .

The C standard is rather terse here. Perhaps we could make the reader's life a little easier. How about something like:

[[
This a type that is intended to be the implementation's most efficient floating type that is at least as wide as .IR float .
]]

Quoted 11 lines
man7/system_data_types.7 +11 -0
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I float_t
+is
+.IR float .
+.IP *
+1;
+.I float_t

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 179

Quoted 10 lines
man7/system_data_types.7 +10 -0
+is
+.IR double .
+.IP *
+2;
+.I float_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE

I think we can format this better as a hanging list. Something like this:

[[
.TP
0
.I float_t
is
.IR float .
.TP
1
.I float_t
is
.IR double .
.TP
2
.I float_t
is
.IR "long double" .
.IP
For other values of
.BR FLT_EVAL_METHOD ,
the type of
.I float_t
is implementation-defined.
]]

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 188

Quoted 9 lines
man7/system_data_types.7 +6 -0
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I double_t
+type in this page.
 .\"------------------------------------- gid_t ------------------------/
 .TP
 .I gid_t

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#9 lore raw

Re: [PATCH 04/10] system_data_types.7: Add float_t

Hi Michael,

Quoted 9 lines · Michael Kerrisk (man-pages)

Hi Alex,

A few comments here that also apply for the double_t patch. Could you revise please?

Quoted 2 lines · Alejandro Colomar

+The implementation's most efficient floating type at least as wide as +.IR float .

Quoted 8 lines

The C standard is rather terse here. Perhaps we could make the reader's life a little easier. How about something like:

[[
This a type that is intended to be the implementation's most efficient floating type that is at least as wide as .IR float .
]]

I removed the "intended" part to simplify it a bit. Do you prefer to keep it?

Quoted 41 lines
Quoted 12 lines
man7/system_data_types.7 +11 -0
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I float_t
+is
+.IR float .
+.IP *
+1;
+.I float_t

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 179

Quoted 10 lines
man7/system_data_types.7 +10 -0
+is
+.IR double .
+.IP *
+2;
+.I float_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE

I think we can format this better as a hanging list. Something like this:

[[
.TP
0
.I float_t
is
.IR float .
.TP
1
.I float_t
is
.IR double .
.TP
2
.I float_t
is

Quoted 8 lines

.IR "long double" .
.IP
For other values of
.BR FLT_EVAL_METHOD ,
the type of
.I float_t
is implementation-defined.
]

Yes, I wasn't convinced by my formatting. Thanks!

I'll fix this patch, and the srcfix that depends on this too.

BTW, I'll also add a note that FLT_EVAL_METHOD is defined in <float.h> Would you add that to "Notes", or as part of the description?

Quoted 13 lines

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 188

Quoted 10 lines

+.IP

man7/system_data_types.7 +5 -0
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I double_t
+type in this page.
  .\"------------------------------------- gid_t ------------------------/
  .TP
  .I gid_t

Thanks,

Quoted 3 lines

Michael

Thanks,

Alex

#10 lore raw

Re: [PATCH 04/10] system_data_types.7: Add float_t

Hi Alex,

Quoted 15 lines · Alejandro Colomar

Hi Michael,

Quoted 12 lines · Michael Kerrisk (man-pages)

Hi Alex,

A few comments here that also apply for the double_t patch. Could you revise please?

Quoted 2 lines · Alejandro Colomar

+The implementation's most efficient floating type at least as wide as +.IR float .

The C standard is rather terse here. Perhaps we could make the reader's life a little easier. How about something like:

Quoted 8 lines
Quoted 5 lines

[[
This a type that is intended to be the implementation's most efficient floating type that is at least as wide as .IR float .
]]

I removed the "intended" part to simplify it a bit. Do you prefer to keep it?

Well, as long as you are going to lift the detail about "most efficient" from the C standard, I'd be inclined to keep the word "intended" from the standard as well. But I do not feel strongly about it.

Quoted 48 lines
Quoted 40 lines
Quoted 11 lines
man7/system_data_types.7 +11 -0
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I float_t
+is
+.IR float .
+.IP *
+1;
+.I float_t

man7/system_data_types.7 Conforming to: C99 and later; POSIX.1-2001 and later. · line 179

Quoted 10 lines
man7/system_data_types.7 +10 -0
+is
+.IR double .
+.IP *
+2;
+.I float_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE

I think we can format this better as a hanging list. Something like this:

[[
.TP
0
.I float_t
is
.IR float .
.TP
1
.I float_t
is
.IR double .
.TP
2
.I float_t
is

Quoted 8 lines

.IR "long double" .
.IP
For other values of
.BR FLT_EVAL_METHOD ,
the type of
.I float_t
is implementation-defined.
]

Quoted 3 lines

Yes, I wasn't convinced by my formatting. Thanks!

I'll fix this patch, and the srcfix that depends on this too.

Okay.

Quoted 2 lines

BTW, I'll also add a note that FLT_EVAL_METHOD is defined in <float.h> Would you add that to "Notes", or as part of the description?

As part of the description I think. (And I don't mind if it's repeated in the double_t description.)

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#11 lore raw

PATCH v2 4/10 system_data_types.7: Add float_t

---

Hi Michael,

Quoted 7 lines · Michael Kerrisk (man-pages)
Quoted 2 lines

I removed the "intended" part to simplify it a bit. Do you prefer to keep it?

Well, as long as you are going to lift the detail about "most efficient" from the C standard, I'd be inclined to keep the word "intended" from the standard as well. But I do not feel strongly about it.

Fair enough.

Quoted 4 lines · Michael Kerrisk (man-pages)
Quoted 2 lines

BTW, I'll also add a note that FLT_EVAL_METHOD is defined in <float.h> Would you add that to "Notes", or as part of the description?

As part of the description I think. (And I don't mind if it's repeated in the double_t description.)

I think there was a misunderstanding; maybe I should have been clearer:

I meant to write about <float.h> in the "Notes" of the type, and not in the "NOTES" of the entire page.

However, I decided to do it in the description of the type as you said, because it was a bit simpler.

The other version would have resulted in this code, just for you to see:

[[
.TP
.I double_t
.RS
.PP
Include:
.IR <math.h> .
.PP
The implementation's most efficient floating type at least as wide as .IR double .
Its type depends on the value of the macro
.BR FLT_EVAL_METHOD :
.TP
0
.I double_t
is
.IR double .
.TP
1
.I double_t
is
.IR double .
.TP
2
.I double_t
is
.IR "long double" .
.IP
For other values of
.BR FLT_EVAL_METHOD ,
the type of
.I double_t
is implementation-defined.
.PP
Conforming to: C99 and later; POSIX.1-2001 and later.
.PP
Notes: The macro
.B FLT_EVAL_METHOD
is defined in
.IR <float.h> .
.PP
See also the
.I float_t
type in this page.
.RE
]]

Cheers,

Alex

 man7/system_data_types.7 | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
man7/system_data_types.7 +42 -0
index b04457bbf..aa5ab95e9 100644
@@ -147,6 +147,48 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR fenv (3)
+.\"------------------------------------- float_t ----------------------/
+.TP
+.I float_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR float .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD ,
+defined in
+.IR <float.h> :
+.RS
+.TP
+0
+.I float_t
+is
+.IR float .
+.TP
+1
+.I float_t
+is
+.IR double .
+.TP
+2
+.I float_t
+is
+.IR "long double" .
+.IP
+For other values of
+.BR FLT_EVAL_METHOD ,
+the type of
+.I float_t
+is implementation-defined.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I double_t
+type in this page.
 .\"------------------------------------- gid_t ------------------------/
 .TP
 .I gid_t
Signature · 1 line
2.28.0
#12 lore raw

Re: [PATCH v2 04/10] system_data_types.7: Add float_t

Hi Alex,

Quoted 20 lines · Alejandro Colomar

---

Hi Michael,

Quoted 7 lines · Michael Kerrisk (man-pages)
Quoted 2 lines

I removed the "intended" part to simplify it a bit. Do you prefer to keep it?

Well, as long as you are going to lift the detail about "most efficient" from the C standard, I'd be inclined to keep the word "intended" from the standard as well. But I do not feel strongly about it.

Fair enough.

Quoted 2 lines · Michael Kerrisk (man-pages)
Quoted 2 lines

BTW, I'll also add a note that FLT_EVAL_METHOD is defined in <float.h> Would you add that to "Notes", or as part of the description?

Quoted 7 lines
Quoted 2 lines

As part of the description I think. (And I don't mind if it's repeated in the double_t description.)

I think there was a misunderstanding; maybe I should have been clearer:

I meant to write about <float.h> in the "Notes" of the type, and not in the "NOTES" of the entire page.

Okay -- got it now.

Quoted 5 lines

However, I decided to do it in the description of the type as you said, because it was a bit simpler.

The other version would have resulted in this code, just for you to see:

I think the path you took was better. I've applied the patch and done some very light editing.

Thanks,

Michael

Quoted 110 lines

[[
.TP
.I double_t
.RS
.PP
Include:
.IR <math.h> .
.PP
The implementation's most efficient floating type at least as wide as .IR double .
Its type depends on the value of the macro
.BR FLT_EVAL_METHOD :
.TP
0
.I double_t
is
.IR double .
.TP
1
.I double_t
is
.IR double .
.TP
2
.I double_t
is
.IR "long double" .
.IP
For other values of
.BR FLT_EVAL_METHOD ,
the type of
.I double_t
is implementation-defined.
.PP
Conforming to: C99 and later; POSIX.1-2001 and later.
.PP
Notes: The macro
.B FLT_EVAL_METHOD
is defined in
.IR <float.h> .
.PP
See also the
.I float_t
type in this page.
.RE
]]

Cheers,

Alex

 man7/system_data_types.7 | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
man7/system_data_types.7 +42 -0
index b04457bbf..aa5ab95e9 100644
@@ -147,6 +147,48 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR fenv (3)
+.\"------------------------------------- float_t ----------------------/
+.TP
+.I float_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR float .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD ,
+defined in
+.IR <float.h> :
+.RS
+.TP
+0
+.I float_t
+is
+.IR float .
+.TP
+1
+.I float_t
+is
+.IR double .
+.TP
+2
+.I float_t
+is
+.IR "long double" .
+.IP
+For other values of
+.BR FLT_EVAL_METHOD ,
+the type of
+.I float_t
+is implementation-defined.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I double_t
+type in this page.
 .\"------------------------------------- gid_t ------------------------/
 .TP
 .I gid_t
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#14 lore raw

Re: [PATCH 05/10] float_t.3: New link to system_data_types(7)

Quoted 1 line · Alejandro Colomar

Applied. Thanks, Alex.

Cheers,

Michael

Quoted 13 lines
---
 man3/float_t.3 | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 man3/float_t.3
man3/float_t.3 new file +1 -0
new file mode 100644
index 000000000..db50c0f09
@@ -0,0 +1 @@
+.so man7/system_data_types.7
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#15 lore raw

PATCH 6/10 system_data_types.7: Add double_t

In reply to Alejandro Colomar
---
 man7/system_data_types.7 | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
man7/system_data_types.7 +36 -0
index 238b9593b..43e88942a 100644
@@ -117,6 +117,42 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR div (3)
+.\"------------------------------------- double_t ---------------------/
+.TP
+.I double_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR double .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I double_t
+is
+.IR double .
+.IP *
+1;
+.I double_t
+is
+.IR double .
+.IP *
+2;
+.I double_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I float_t
+type in this page.
 .\"------------------------------------- fenv_t -----------------------/
 .TP
 .I fenv_t
Signature · 1 line
2.28.0
#16 lore raw

PATCH v2 6/10 system_data_types.7: Add double_t

---
 man7/system_data_types.7 | 42 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
man7/system_data_types.7 +42 -0
index aa5ab95e9..7730815d4 100644
@@ -117,6 +117,48 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR div (3)
+.\"------------------------------------- double_t ---------------------/
+.TP
+.I double_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR double .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD ,
+defined in
+.IR <float.h> :
+.RS
+.TP
+0
+.I double_t
+is
+.IR double .
+.TP
+1
+.I double_t
+is
+.IR double .
+.TP
+2
+.I double_t
+is
+.IR "long double" .
+.IP
+For other values of
+.BR FLT_EVAL_METHOD ,
+the type of
+.I double_t
+is implementation-defined.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I float_t
+type in this page.
 .\"------------------------------------- fenv_t -----------------------/
 .TP
 .I fenv_t
Signature · 1 line
2.28.0
#17 lore raw

Re: [PATCH 06/10] system_data_types.7: Add double_t

In reply to Alejandro Colomar
Quoted 1 line · Alejandro Colomar

Applied. Thanks, Alex.

Cheers,

Michael

Quoted 52 lines
---
 man7/system_data_types.7 | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)
man7/system_data_types.7 +36 -0
index 238b9593b..43e88942a 100644
@@ -117,6 +117,42 @@ Conforming to: C99 and later; POSIX.1-2001 and later.
 .IP
 See also:
 .BR div (3)
+.\"------------------------------------- double_t ---------------------/
+.TP
+.I double_t
+.IP
+Include:
+.IR <math.h> .
+.IP
+The implementation's most efficient floating type at least as wide as
+.IR double .
+Its type depends on the value of the macro
+.BR FLT_EVAL_METHOD :
+.RS
+.IP *
+0;
+.I double_t
+is
+.IR double .
+.IP *
+1;
+.I double_t
+is
+.IR double .
+.IP *
+2;
+.I double_t
+is
+.IR "long double" .
+.IP *
+Other implementation-defined values.
+.RE
+.IP
+Conforming to: C99 and later; POSIX.1-2001 and later.
+.IP
+See also the
+.I float_t
+type in this page.
 .\"------------------------------------- fenv_t -----------------------/
 .TP
 .I fenv_t
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#19 lore raw

Re: [PATCH 07/10] double_t.3: New link to system_data_types(7)

Quoted 1 line · Alejandro Colomar

Applied. Thanks, Alex.

Cheers,

Michael

Quoted 13 lines
---
 man3/double_t.3 | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 man3/double_t.3
man3/double_t.3 new file +1 -0
new file mode 100644
index 000000000..db50c0f09
@@ -0,0 +1 @@
+.so man7/system_data_types.7
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#20 lore raw

PATCH 8/10 seccomp.2: Remove unneeded cast

In reply to Alejandro Colomar
---
 man2/seccomp.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/seccomp.2 +1 -1
index 58033da1c..d6b856c32 100644
@@ -1101,7 +1101,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
     };
 
     struct sock_fprog prog = {
-        .len = (unsigned short) (sizeof(filter) / sizeof(filter[0])),
+        .len = sizeof(filter) / sizeof(filter[0]),
         .filter = filter,
     };
 
Signature · 1 line
2.28.0
#21 lore raw

Re: [PATCH 08/10] seccomp.2: Remove unneeded cast

Hi Alex,

Quoted 10 lines · Alejandro Colomar
---
 man2/seccomp.2 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
man2/seccomp.2 +0 -0
index 58033da1c..d6b856c32 100644

man2/seccomp.2 install_filter(int syscall_nr, int t_arch, int f_errno) · line 1106

Quoted 7 lines
man2/seccomp.2 +1 -1
@@ -1101,7 +1101,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
     };
 
     struct sock_fprog prog = {
-        .len = (unsigned short) (sizeof(filter) / sizeof(filter[0])),
+        .len = sizeof(filter) / sizeof(filter[0]),
         .filter = filter,
     };

I have a small doubt about this change. With the change, there are no compilation warnings.

But, if we change the code to something slightly different:

[[

    size_t x = (sizeof(filter) / sizeof(filter[0]));
    struct sock_fprog prog = {
        .len = x,
        .filter = filter,
    };

]]

The "cc -Wconversion" gives us the following warning:

warning: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘short unsigned int’ may change value

Presumably we don't get a warning for an assignment of the form

    .len = (sizeof(filter) / sizeof(filter[0]))

because the compiler is smart enough to work out that the value of the constant expression is within the range of "unsigned short".

Your thoughts?

Thanks,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#22 lore raw

Re: [PATCH 08/10] seccomp.2: Remove unneeded cast

Quoted 41 lines · Michael Kerrisk (man-pages)

Hi Alex,

Quoted 10 lines · Alejandro Colomar
---
  man2/seccomp.2 | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
man2/seccomp.2 +0 -0
index 58033da1c..d6b856c32 100644

man2/seccomp.2 install_filter(int syscall_nr, int t_arch, int f_errno) · line 1106

Quoted 7 lines
man2/seccomp.2 +1 -1
@@ -1101,7 +1101,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
      };
 
      struct sock_fprog prog = {
-        .len = (unsigned short) (sizeof(filter) / sizeof(filter[0])),
+        .len = sizeof(filter) / sizeof(filter[0]),
          .filter = filter,
      };

I have a small doubt about this change. With the change, there are no compilation warnings.

But, if we change the code to something slightly different:

[[

     size_t x = (sizeof(filter) / sizeof(filter[0]));
     struct sock_fprog prog = {
         .len = x,
         .filter = filter,
     };

]]

The "cc -Wconversion" gives us the following warning:

warning: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘short unsigned int’ may change value

Presumably we don't get a warning for an assignment of the form

Quoted 7 lines
     .len = (sizeof(filter) / sizeof(filter[0]))

because the compiler is smart enough to work out that the value of the constant expression is within the range of "unsigned short".

Your thoughts?

Hi Michael,

I'd say that the cast doesn't fix any problems at all. It silences a valid warning, and I'd use a pragma for that (to be more explicit about the intention of silencing a warning) if I do want -Wconversion enabled (which usually I don't want, because it's too noisy) and I'm sure that this won't overflow. I'd limit the use casts to only when I *really* need to.

I guess that if you enable -O3, the warning will vanish again because the compiler will optimize away 'x' (but I didn't test).

Thanks,

Alex

Quoted 6 lines

Thanks,

Michael

#23 lore raw

Re: [PATCH 08/10] seccomp.2: Remove unneeded cast

Quoted 61 lines · Alejandro Colomar
Quoted 41 lines · Michael Kerrisk (man-pages)

Hi Alex,

Quoted 10 lines · Alejandro Colomar
---
  man2/seccomp.2 | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
man2/seccomp.2 +0 -0
index 58033da1c..d6b856c32 100644

man2/seccomp.2 install_filter(int syscall_nr, int t_arch, int f_errno) · line 1106

Quoted 7 lines
man2/seccomp.2 +1 -1
@@ -1101,7 +1101,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
      };
 
      struct sock_fprog prog = {
-        .len = (unsigned short) (sizeof(filter) / sizeof(filter[0])),
+        .len = sizeof(filter) / sizeof(filter[0]),
          .filter = filter,
      };

I have a small doubt about this change. With the change, there are no compilation warnings.

But, if we change the code to something slightly different:

[[

     size_t x = (sizeof(filter) / sizeof(filter[0]));
     struct sock_fprog prog = {
         .len = x,
         .filter = filter,
     };

]]

The "cc -Wconversion" gives us the following warning:

warning: conversion from ‘size_t’ {aka ‘long unsigned int’} to ‘short unsigned int’ may change value

Presumably we don't get a warning for an assignment of the form

Quoted 7 lines
     .len = (sizeof(filter) / sizeof(filter[0]))

because the compiler is smart enough to work out that the value of the constant expression is within the range of "unsigned short".

Your thoughts?

Hi Michael,

I'd say that the cast doesn't fix any problems at all. It silences a valid warning, and I'd use a pragma for that (to be more explicit about the intention of silencing a warning) if I do want -Wconversion enabled (which usually I don't want, because it's too noisy) and I'm sure that this won't overflow. I'd limit the use casts to only when I *really* need to.

Quoted 2 lines

I guess that if you enable -O3, the warning will vanish again because the compiler will optimize away 'x' (but I didn't test).

Fair enough! I've applied the patch. Thanks!

Cheers,

Michael

Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#24 lore raw

PATCH 9/10 seccomp.2: Use ARRAY_SIZE() macro instead of raw sizeof division

In reply to Alejandro Colomar
---
 man2/seccomp.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man2/seccomp.2 +2 -1
index d6b856c32..82eb04dc6 100644
@@ -1051,6 +1051,7 @@ cecilia
 #include <sys/prctl.h>
 
 #define X32_SYSCALL_BIT 0x40000000
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static int
 install_filter(int syscall_nr, int t_arch, int f_errno)
@@ -1101,7 +1102,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
     };
 
     struct sock_fprog prog = {
-        .len = sizeof(filter) / sizeof(filter[0]),
+        .len = ARRAY_SIZE(filter),
         .filter = filter,
     };
 
Signature · 1 line
2.28.0
#25 lore raw

Re: [PATCH 09/10] seccomp.2: Use ARRAY_SIZE() macro instead of raw sizeof division

Quoted 1 line · Alejandro Colomar

Thanks, Alex. Patch applied.

Cheers,

Michael

Quoted 26 lines
---
 man2/seccomp.2 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man2/seccomp.2 +2 -1
index d6b856c32..82eb04dc6 100644
@@ -1051,6 +1051,7 @@ cecilia
 #include <sys/prctl.h>
 
 #define X32_SYSCALL_BIT 0x40000000
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 
 static int
 install_filter(int syscall_nr, int t_arch, int f_errno)
@@ -1101,7 +1102,7 @@ install_filter(int syscall_nr, int t_arch, int f_errno)
     };
 
     struct sock_fprog prog = {
-        .len = sizeof(filter) / sizeof(filter[0]),
+        .len = ARRAY_SIZE(filter),
         .filter = filter,
     };
 
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
#26 lore raw

PATCH 10/10 getgrent_r.3: Declare variables with different types in different lines

In reply to Alejandro Colomar
---
 man3/getgrent_r.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/getgrent_r.3 +2 -1
index 8170cd417..64d7f3ac1 100644
@@ -181,7 +181,8 @@ in the stream with all other threads.
 int
 main(void)
 {
-    struct group grp, *grpp;
+    struct group grp;
+    struct group *grpp;
     char buf[BUFLEN];
     int i;
 
Signature · 1 line
2.28.0
#27 lore raw

Re: [PATCH 10/10] getgrent_r.3: Declare variables with different types in different lines

Quoted 1 line · Alejandro Colomar

Thanks, Alex. Patch applied.

Cheers,

Michael

Quoted 19 lines
---
 man3/getgrent_r.3 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
man3/getgrent_r.3 +2 -1
index 8170cd417..64d7f3ac1 100644
@@ -181,7 +181,8 @@ in the stream with all other threads.
 int
 main(void)
 {
-    struct group grp, *grpp;
+    struct group grp;
+    struct group *grpp;
     char buf[BUFLEN];
     int i;
 
Signature · 3 lines
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/