uintptr_t can always hold a pointer but long may not. In practice it doesn't matter on non-Windows, though. Anyway, the important part is not the cast at all but rather the fact that 'fi->fh' needs to be used and not 'fi'...
On Sat, Oct 29, 2016 at 10:38:45AM +0200, Jean-Pierre André wrote: > Hi again, > > The "#ifdef PLUGIN_ENABLED" part is a major bug eligible > for the next version. > > The "uintptr_t" casts are more debatable, because this is > defined as an optional type in C11 (section 7.20.1.4). > This is probably why fh is not declared as uintptr_t in > "fuse_common.h". Nevertheless, you are right, the cast to > long is wrong in 64-bit environments which define long as > a 32-bit integer (and the equivalent type for that on > Windows is ULONG_PTR). The real question is "Is there an > environment which defines uintptr_t different from unsigned > long ?" > > As doing something about it in "configure" would be > overkilling, I will probably take the proposal for next > version. > > Jean-Pierre > > Eric Biggers wrote: > > Signed-off-by: Eric Biggers <ebigge...@gmail.com> > > --- > > src/lowntfs-3g.c | 14 +++++++------- > > 1 file changed, 7 insertions(+), 7 deletions(-) > > > > diff --git a/src/lowntfs-3g.c b/src/lowntfs-3g.c > > index a91d123..9d933d2 100644 > > --- a/src/lowntfs-3g.c > > +++ b/src/lowntfs-3g.c > > @@ -1493,15 +1493,15 @@ close: > > of->parent = 0; > > of->ino = ino; > > of->state = state; > > -#ifdef PLUGIN_ENABLED > > +#ifndef PLUGINS_DISABLED > > memcpy(&of->fi, fi, sizeof(struct fuse_file_info)); > > -#endif /* PLUGIN_ENABLED */ > > +#endif /* PLUGINS_DISABLED */ > > of->next = ctx->open_files; > > of->previous = (struct open_file*)NULL; > > if (ctx->open_files) > > ctx->open_files->previous = of; > > ctx->open_files = of; > > - fi->fh = (long)of; > > + fi->fh = (uintptr_t)of; > > } > > } > > if (res) > > @@ -1542,7 +1542,7 @@ static void ntfs_fuse_read(fuse_req_t req, fuse_ino_t > > ino, size_t size, > > REPARSE_POINT *reparse; > > struct open_file *of; > > > > - of = (struct open_file*)fi; > > + of = (struct open_file*)(uintptr_t)fi->fh; > > res = CALL_REPARSE_PLUGIN(ni, read, buf, size, offset, &of->fi); > > if (res >= 0) { > > goto stamps; > > @@ -1623,7 +1623,7 @@ static void ntfs_fuse_write(fuse_req_t req, > > fuse_ino_t ino, const char *buf, > > REPARSE_POINT *reparse; > > struct open_file *of; > > > > - of = (struct open_file*)fi; > > + of = (struct open_file*)(uintptr_t)fi->fh; > > res = CALL_REPARSE_PLUGIN(ni, write, buf, size, offset, > > &of->fi); > > if (res >= 0) { > > @@ -2283,7 +2283,7 @@ exit: > > if (ctx->open_files) > > ctx->open_files->previous = of; > > ctx->open_files = of; > > - fi->fh = (long)of; > > + fi->fh = (uintptr_t)of; > > } > > } > > return res; > > @@ -2774,7 +2774,7 @@ static void ntfs_fuse_release(fuse_req_t req, > > fuse_ino_t ino, > > char ghostname[GHOSTLTH]; > > int res; > > > > - of = (struct open_file*)(long)fi->fh; > > + of = (struct open_file*)(uintptr_t)fi->fh; > > /* Only for marked descriptors there is something to do */ > > if (!of > > || !(of->state & (CLOSE_COMPRESSED | CLOSE_ENCRYPTED > > > ------------------------------------------------------------------------------ The Command Line: Reinvented for Modern Developers Did the resurgence of CLI tooling catch you by surprise? Reconnect with the command line and become more productive. Learn the new .NET and ASP.NET CLI. Get your free copy! http://sdm.link/telerik _______________________________________________ ntfs-3g-devel mailing list ntfs-3g-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel