[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH 1/1] switch_root: Fix undefined fd and minor tweak
From:       Andrei Gherzan <andrei () gherzan ! com>
Date:       2017-04-05 12:46:02
Message-ID: CAK18fxEok0iG_AHkET7+DVt5Cus9usphmeUr_9fiPOm+1FFrFQ () mail ! gmail ! com
[Download RAW message or body]

Hi guys,

On Wed, Apr 5, 2017 at 1:26 PM, Denys Vlasenko <vda.linux@googlemail.com> wrote:
> On Fri, Mar 31, 2017 at 7:34 AM, Rafał Miłecki <zajec5@gmail.com> wrote:
>> On 03/30/2017 06:19 PM, Andrei Gherzan wrote:
>>>
>>> On Fri, Mar 24, 2017 at 3:56 PM, Andrei Gherzan <andrei@gherzan.com>
>>> wrote:
>>>>
>>>> Signed-off-by: Andrei Gherzan <andrei@gherzan.com>
>>>> ---
>>>>  util-linux/switch_root.c | 4 ++--
>>>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/util-linux/switch_root.c b/util-linux/switch_root.c
>>>> index aaee35a3e..cae61d5ac 100644
>>>> --- a/util-linux/switch_root.c
>>>> +++ b/util-linux/switch_root.c
>>>> @@ -96,6 +96,7 @@ int switch_root_main(int argc UNUSED_PARAM, char
>>>> **argv)
>>>>         struct stat st;
>>>>         struct statfs stfs;
>>>>         dev_t rootdev;
>>>> +       int fd;
>>>>
>>>>         // Parse args (-c console)
>>>>         opt_complementary = "-2"; // minimum 2 params
>>>> @@ -141,8 +142,7 @@ int switch_root_main(int argc UNUSED_PARAM, char
>>>> **argv)
>>>>
>>>>         // If a new console specified, redirect stdin/stdout/stderr to it
>>>>         if (console) {
>>>> -               int fd = open_or_warn(console, O_RDWR);
>>>> -               if (fd >= 0) {
>>>> +               if ((fd = open_or_warn(console, O_RDWR)) >= 0) {
>>>>                         xmove_fd(fd, 0);
>>>>                         xdup2(0, 1);
>>>>                         xdup2(0, 2);
>>>> --

The commit log is indeed wrong. The fd was defined before. It was more
of a restructuring so that the fs would be defined where all the other
variables are. It was more of a cosmetics change.

Regards,
Andrei
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic