[PATCH] prims: Bit-and the flags instead of using boolean operation

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] prims: Bit-and the flags instead of using boolean operation

Holger Freyther
This was pointed out by the clang compiler. Current access can
be either 0 or 1 but I think we want to be able to pass it as
integer as well. It looks like this code has never been executed
and we might just remove the call by number.

2014-09-13  Holger Hans Peter Freyther  <[hidden email]>

        * prims.def: Use & instead of && for the flags value.
---
 libgst/ChangeLog | 4 ++++
 libgst/prims.def | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/libgst/ChangeLog b/libgst/ChangeLog
index a390754..e157c68 100644
--- a/libgst/ChangeLog
+++ b/libgst/ChangeLog
@@ -1,3 +1,7 @@
+2014-09-13  Holger Hans Peter Freyther  <[hidden email]>
+
+ * prims.def: Use & instead of && for the flags value.
+
 2014-08-02  Holger Hans Peter Freyther  <[hidden email]>
 
  * prims.def: Introduce VMpr_Behavior_newInitialize and
diff --git a/libgst/prims.def b/libgst/prims.def
index 431ec2b..98e5c68 100644
--- a/libgst/prims.def
+++ b/libgst/prims.def
@@ -5538,7 +5538,7 @@ primitive VMpr_FileDescriptor_fileOp [succeed,fail]
       if (IS_INT (oopVec[2]) && arg1 == PRIM_OPEN_FILE)
         {
           fd = open ((char *) fileName, TO_INT (oopVec[2]));
-  access = TO_INT (oopVec[2]) && (O_RDONLY | O_WRONLY | O_RDWR);
+  access = TO_INT (oopVec[2]) & (O_RDONLY | O_WRONLY | O_RDWR);
  }
 
       else if (!is_a_kind_of (OOP_CLASS (oopVec[1]), _gst_string_class))
--
2.1.0


_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] prims: Bit-and the flags instead of using boolean operation

Holger Freyther
On Sat, Sep 13, 2014 at 08:25:24PM +0200, Holger Hans Peter Freyther wrote:

Dear Paolo,



> This was pointed out by the clang compiler. Current access can
> be either 0 or 1 but I think we want to be able to pass it as
> integer as well. It looks like this code has never been executed
> and we might just remove the call by number.

what do you think about removing it? I added an abort to the codepath
and ran make check. It is not hit and I don't think external code is
calling that primitive either.

holger

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] prims: Bit-and the flags instead of using boolean operation

Paolo Bonzini-2
In reply to this post by Holger Freyther
Il 13/09/2014 20:25, Holger Hans Peter Freyther ha scritto:
> -  access = TO_INT (oopVec[2]) && (O_RDONLY | O_WRONLY | O_RDWR);
> +  access = TO_INT (oopVec[2]) & (O_RDONLY | O_WRONLY | O_RDWR);
>   }

Of course...

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] prims: Bit-and the flags instead of using boolean operation

Paolo Bonzini-2
In reply to this post by Holger Freyther
Il 13/09/2014 20:58, Holger Hans Peter Freyther ha scritto:

> On Sat, Sep 13, 2014 at 08:25:24PM +0200, Holger Hans Peter Freyther wrote:
>
> Dear Paolo,
>
>
>
>> This was pointed out by the clang compiler. Current access can
>> be either 0 or 1 but I think we want to be able to pass it as
>> integer as well. It looks like this code has never been executed
>> and we might just remove the call by number.
>
> what do you think about removing it? I added an abort to the codepath
> and ran make check. It is not hit and I don't think external code is
> calling that primitive either.

Yeah, it's not been used for several years probably, and DLD would be a
better way to hook into open(2) nowadays.

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-smalltalk