apps/Nxwidgets: Fix some recently introduced errors found in build testing.

This commit is contained in:
Gregory Nutt 2019-03-08 16:26:34 -06:00
parent e4e00f716f
commit 66af5b46dd
3 changed files with 37 additions and 26 deletions

View File

@ -220,7 +220,7 @@ void CCallback::newKeyboardEvent(NXHANDLE hwnd, uint8_t nCh,
kbdin.buffer = str;
kbdin.buflen = nCh;
(void)boardctl(BOARDIOC_NXTERM_KBDIN, (uintptr_t)&kbin);
(void)boardctl(BOARDIOC_NXTERM_KBDIN, (uintptr_t)&kbdin);
}
else
#endif

View File

@ -250,6 +250,10 @@ bool CNxTerm::run(void)
g_nxtermvars.wndo.fcolor[0] = CONFIG_NXWM_NXTERM_FONTCOLOR;
g_nxtermvars.wndo.fontid = CONFIG_NXWM_NXTERM_FONTID;
// Remember the device minor number (before it is incremented)
m_minor = g_nxtermvars.minor;
// Get the size of the window
(void)window->getSize(&g_nxtermvars.wndo.wsize);
@ -348,8 +352,12 @@ void CNxTerm::stop(void)
#endif
// Unlink the NxTerm driver
// Construct the driver name using this minor number
(void)unlink(m_devname);
char devname[32];
snprintf(devname, 32, "/dev/nxterm%d", m_minor);
(void)unlink(devname);
m_nxterm = 0;
}
}
@ -439,6 +447,7 @@ int CNxTerm::nxterm(int argc, char *argv[])
// of 'int fd'
int fd = -1;
int ret = OK;
// Set up an on_exit() event that will be called when this task exits
@ -470,7 +479,8 @@ int CNxTerm::nxterm(int argc, char *argv[])
// Construct the driver name using this minor number
snprintf(m_devname, 32, "/dev/nxterm%d", g_nxtermvars.minor);
char devname[32];
snprintf(devname, 32, "/dev/nxterm%d", g_nxtermvars.minor);
// Increment the minor number while it is protect by the semaphore
@ -479,14 +489,15 @@ int CNxTerm::nxterm(int argc, char *argv[])
// Open the NxTerm driver
#ifdef CONFIG_NXTERM_NXKBDIN
fd = open(m_devname, O_RDWR);
fd = open(devname, O_RDWR);
#else
fd = open(m_devname, O_WRONLY);
fd = open(devname, O_WRONLY);
#endif
if (fd < 0)
{
gerr("ERROR: Failed open the console device\n");
goto errout_with_nxterm;
(void)unlink(devname);
goto errout;
}
// Now re-direct stdout and stderr so that they use the NX console driver.
@ -517,7 +528,10 @@ int CNxTerm::nxterm(int argc, char *argv[])
// And we can close our original driver file descriptor
if (fd > 2)
{
std::close(fd);
}
// Inform the parent thread that we successfully initialized
@ -536,9 +550,6 @@ int CNxTerm::nxterm(int argc, char *argv[])
return EXIT_SUCCESS;
errout_with_nxterm:
(void)unlink(m_devname);
errout:
g_nxtermvars.nxterm = 0;
g_nxtermvars.result = false;

View File

@ -82,7 +82,7 @@ namespace NxWM
CApplicationWindow *m_window; /**< Reference to the application window */
NXTERM m_nxterm; /**< NxTerm handle */
pid_t m_pid; /**< Task ID of the NxTerm thread */
char m_devname[32]; /**< Terminal device name *.
int m_minor; /**< Terminal device minor number */
/**
* This is the NxTerm task. This function first redirects output to the