diff mbox

[09/16] os-posix: cleanup: Replace fprintfs with error_report in change_process_uid

Message ID 1524592709-6553-10-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson April 24, 2018, 5:58 p.m. UTC
I'm going to be editing this function and it makes sense to clean up
this style problem in advance.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: Markus Armbruster <armbru@redhat.com>
CC: Daniel P. Berrange <berrange@redhat.com>
CC: Michael Tokarev <mjt@tls.msk.ru>
---
 os-posix.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Peter Maydell April 24, 2018, 7:09 p.m. UTC | #1
On 24 April 2018 at 18:58, Ian Jackson <ian.jackson@eu.citrix.com> wrote:
> I'm going to be editing this function and it makes sense to clean up
> this style problem in advance.
>
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Daniel P. Berrange <berrange@redhat.com>
> CC: Michael Tokarev <mjt@tls.msk.ru>
> ---

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

thanks
-- PMM
Thomas Huth April 25, 2018, 4:05 a.m. UTC | #2
On 24.04.2018 19:58, Ian Jackson wrote:
> I'm going to be editing this function and it makes sense to clean up
> this style problem in advance.
> 
> Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
> CC: Paolo Bonzini <pbonzini@redhat.com>
> CC: Markus Armbruster <armbru@redhat.com>
> CC: Daniel P. Berrange <berrange@redhat.com>
> CC: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  os-posix.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/os-posix.c b/os-posix.c
> index b9c2343..560db95 100644
> --- a/os-posix.c
> +++ b/os-posix.c
> @@ -167,20 +167,20 @@ static void change_process_uid(void)
>  {
>      if (user_pwd) {
>          if (setgid(user_pwd->pw_gid) < 0) {
> -            fprintf(stderr, "Failed to setgid(%d)\n", user_pwd->pw_gid);
> +            error_report("Failed to setgid(%d)", user_pwd->pw_gid);
>              exit(1);
>          }
>          if (initgroups(user_pwd->pw_name, user_pwd->pw_gid) < 0) {
> -            fprintf(stderr, "Failed to initgroups(\"%s\", %d)\n",
> -                    user_pwd->pw_name, user_pwd->pw_gid);
> +            error_report("Failed to initgroups(\"%s\", %d)",
> +                         user_pwd->pw_name, user_pwd->pw_gid);
>              exit(1);
>          }
>          if (setuid(user_pwd->pw_uid) < 0) {
> -            fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid);
> +            error_report("Failed to setuid(%d)", user_pwd->pw_uid);
>              exit(1);
>          }
>          if (setuid(0) != -1) {
> -            fprintf(stderr, "Dropping privileges failed\n");
> +            error_report("Dropping privileges failed");
>              exit(1);
>          }
>      }
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox

Patch

diff --git a/os-posix.c b/os-posix.c
index b9c2343..560db95 100644
--- a/os-posix.c
+++ b/os-posix.c
@@ -167,20 +167,20 @@  static void change_process_uid(void)
 {
     if (user_pwd) {
         if (setgid(user_pwd->pw_gid) < 0) {
-            fprintf(stderr, "Failed to setgid(%d)\n", user_pwd->pw_gid);
+            error_report("Failed to setgid(%d)", user_pwd->pw_gid);
             exit(1);
         }
         if (initgroups(user_pwd->pw_name, user_pwd->pw_gid) < 0) {
-            fprintf(stderr, "Failed to initgroups(\"%s\", %d)\n",
-                    user_pwd->pw_name, user_pwd->pw_gid);
+            error_report("Failed to initgroups(\"%s\", %d)",
+                         user_pwd->pw_name, user_pwd->pw_gid);
             exit(1);
         }
         if (setuid(user_pwd->pw_uid) < 0) {
-            fprintf(stderr, "Failed to setuid(%d)\n", user_pwd->pw_uid);
+            error_report("Failed to setuid(%d)", user_pwd->pw_uid);
             exit(1);
         }
         if (setuid(0) != -1) {
-            fprintf(stderr, "Dropping privileges failed\n");
+            error_report("Dropping privileges failed");
             exit(1);
         }
     }