jpilot icon indicating copy to clipboard operation
jpilot copied to clipboard

type mismatch in pi-dlp.h

Open CoSoCo opened this issue 3 years ago • 2 comments

The iterator constants are defined as signed int via enum (line 538):

	/** @brief VFS file iterator constants */
	enum dlpVFSFileIteratorConstants {
		vfsIteratorStart	= 0,		/** < Indicates that iterator is beginning */
		vfsIteratorStop		= -1		/**< Indicate that iterator has gone through all items */
	};

But the iterator function requires an unsigned long diriterator parameter (line 1596):

	extern PI_ERR dlp_VFSDirEntryEnumerate
		PI_ARGS((int sd, FileRef dirref, unsigned long *diriterator, int *maxitems, struct VFSDirInfo *diritems));

This causes an endless loop when using it straight forward (seen in Pics&Videos Plugin) like:

            unsigned long dirIterator = vfsIteratorStart;
            while (dirIterator != vfsIteratorStop) {
                dlp_VFSDirEntryEnumerate(sd, dirRef, &dirIterator, &maxDirItems, dirInfo);
                [.....]
            }

Anyway, there is a workaround, but it's not smart:

            unsigned long dirIterator = (unsigned long)vfsIteratorStart;
            while ((enum dlpVFSFileIteratorConstants)dirIterator != vfsIteratorStop) {
                dlp_VFSDirEntryEnumerate(sd, dirRef, &dirIterator, &maxDirItems, dirInfo);
                [.....]
            }

CoSoCo avatar Jul 23 '22 15:07 CoSoCo

I've found a solution and provided a patch, see here: https://github.com/desrod/pilot-link/issues/7#issuecomment-1215743346

CoSoCo avatar Aug 15 '22 20:08 CoSoCo