From: Christophe CURIS <[email protected]> The C language provides the macro 'sizeof' to handle this kind of situation, so do not create locally a macro which can become a source of problems.
Took opportunity to change the size of buffer to follow guidelines from Inotify's manpage, and to remove the initial value that is useless. Signed-off-by: Christophe CURIS <[email protected]> --- src/event.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/event.c b/src/event.c index c9ff3df..22349fe 100644 --- a/src/event.c +++ b/src/event.c @@ -291,12 +291,11 @@ void DispatchEvent(XEvent * event) * Calls wDefaultsCheckDomains if config database is updated *---------------------------------------------------------------------- */ -/* allow 5 simultaneous events, with path + filenames up to 64 chars */ -#define BUFF_SIZE ((sizeof(struct inotify_event) + 64)*5) static void handle_inotify_events(void) { ssize_t eventQLength, i = 0; - char buff[BUFF_SIZE] = { 0 }; + /* Make room for at lease 5 simultaneous events, with path + filenames */ + char buff[ (sizeof(struct inotify_event) + NAME_MAX + 1) * 5 ]; /* Check config only once per read of the event queue */ int oneShotFlag = 0; @@ -308,7 +307,7 @@ static void handle_inotify_events(void) * a few entries before a read(). */ eventQLength = read(w_global.inotify.fd_event_queue, - buff, BUFF_SIZE); + buff, sizeof(buff) ); /* check what events occured */ /* Should really check wd here too, but for now we only have one watch! */ -- 1.8.4.rc3 -- To unsubscribe, send mail to [email protected].
