Re: [gamin] FAMCancelMonitor - definition should contain const



On Wed, Nov 24, 2004 at 10:58:56PM +0100, Michael Tautschnig wrote:
> >So yes it seems you are right, but this just violates the API as described 
> >!
> What API would it violate? gamin's own?

  FAM one as described ... not as implemented 

> >I note that libgamin does *not* free the structure passed because it did
> >break FAM compatibility .... And should not modify it either, so 
> >technically
> >speaking this is right.
> 
> Doesn't this kind of definition break FAM-compatibility? I don't really 

  FAM defines it as const but say it will free the block. You shiuld find
that obviously susspect. Of course the comment on fam.h (from FAM) is wrong.
If you free the request block, application which worked with FAM will
segfault. The const compiler hint is true, the comment is wrong. They are
obviously incompatible.

------------------
 grep -C 2 FAMCancelMonitor /u/veillard/pkgs/fam/RHEL-3/fam-2.6.8/include/fam.h

 /*****************************************************************************
 *  FAMCancelMonitor
 *
 *  When an application is done monitoring a file/directory, it should
 *  call FAMCancelMonitor.  This routine will signal fam not to watch
 *  this directory anymore. Once again, the FAMRequest structure is
 *  returned from the FAMMonitorFile/Directory routines.
 *
 *  On error, FAMCancelMonitor will return -1 (and the global
 *  FAMErrno will be set to the value of the error).  This routine will free
 *  the FAMRequest structure that is passed in.
 *****************************************************************************/
  
 int FAMCancelMonitor(FAMConnection *fc, const FAMRequest *fr);
------------------

  it can't both free it as documented and say it's "const" !

> get the point, why this has not been defined "const" - actually this 
> breaks applications such as "fileschanged" ...

  I really don't see how this could break the application ! Explain !
A const on a pointer to a structure passed as an argument is just a compiler
hint. If it's missing and the routine does not change the structure this
cannot generate an error.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]