[04/11] syslog: Update misc/tst-syslog to check reported %n value

Message ID 8502804480ab69e7ae48dfe43552e9a6be596711.1707491940.git.fweimer@redhat.com
State Accepted
Delegated to: Adhemerval Zanella Netto
Headers
Series Build getdomainname, gethostname, syslog with fortification |

Checks

Context Check Description
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_glibc_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_glibc_check--master-arm success Testing passed

Commit Message

Florian Weimer Feb. 9, 2024, 3:25 p.m. UTC
  ---
 misc/tst-syslog.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
  

Comments

Adhemerval Zanella Netto Feb. 13, 2024, 11:59 a.m. UTC | #1
The change LGTM, just that it does not follow current file indentation
(tabs instead of whitespace).

On 09/02/24 12:25, Florian Weimer wrote:
> ---
>  misc/tst-syslog.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/misc/tst-syslog.c b/misc/tst-syslog.c
> index ced9ae8467..741693a7ff 100644
> --- a/misc/tst-syslog.c
> +++ b/misc/tst-syslog.c
> @@ -102,8 +102,10 @@ send_vsyslog (int options)
>          {
>            int facility = facilities[i];
>            int priority = priorities[j];
> -          call_vsyslog (facility | priority, "%s %d %d", SYSLOG_MSG_BASE,
> -                        facility, priority);
> +	  int pos = -1;
> +          call_vsyslog (facility | priority, "%n%s %d %d",
> +			&pos, SYSLOG_MSG_BASE, facility, priority);
> +	  TEST_COMPARE (pos, 0);
>          }
>      }
>  }
> @@ -117,8 +119,10 @@ send_syslog (int options)
>          {
>            int facility = facilities[i];
>            int priority = priorities[j];
> -          syslog (facility | priority, "%s %d %d", SYSLOG_MSG_BASE, facility,
> -                  priority);
> +	  int pos = -1;
> +          syslog (facility | priority, "%n%s %d %d",
> +		  &pos, SYSLOG_MSG_BASE, facility, priority);
> +	  TEST_COMPARE (pos, 0);
>          }
>      }
>  }
  
Florian Weimer Feb. 15, 2024, 1:23 p.m. UTC | #2
* Adhemerval Zanella Netto:

> The change LGTM, just that it does not follow current file indentation
> (tabs instead of whitespace).

The file uses tabs elsewhere (e.g., to indent the parameter list in
check_syslog_message_large), that's why Emacs turned on tabs.  Just not
in the edited places.

Thanks,
Florian
  

Patch

diff --git a/misc/tst-syslog.c b/misc/tst-syslog.c
index ced9ae8467..741693a7ff 100644
--- a/misc/tst-syslog.c
+++ b/misc/tst-syslog.c
@@ -102,8 +102,10 @@  send_vsyslog (int options)
         {
           int facility = facilities[i];
           int priority = priorities[j];
-          call_vsyslog (facility | priority, "%s %d %d", SYSLOG_MSG_BASE,
-                        facility, priority);
+	  int pos = -1;
+          call_vsyslog (facility | priority, "%n%s %d %d",
+			&pos, SYSLOG_MSG_BASE, facility, priority);
+	  TEST_COMPARE (pos, 0);
         }
     }
 }
@@ -117,8 +119,10 @@  send_syslog (int options)
         {
           int facility = facilities[i];
           int priority = priorities[j];
-          syslog (facility | priority, "%s %d %d", SYSLOG_MSG_BASE, facility,
-                  priority);
+	  int pos = -1;
+          syslog (facility | priority, "%n%s %d %d",
+		  &pos, SYSLOG_MSG_BASE, facility, priority);
+	  TEST_COMPARE (pos, 0);
         }
     }
 }