From: Rafał Długołęcki Date: Thu, 28 Jan 2016 20:23:53 +0000 (+0100) Subject: Reduce scope of some variables X-Git-Tag: 3.4-b1~29 X-Git-Url: https://git.dlugolecki.net.pl/?p=vlp.git;a=commitdiff_plain;h=cec0990bb3507f23b196891002cd25f80e8bbb40 Reduce scope of some variables --- diff --git a/src/kernel/kernel.cpp b/src/kernel/kernel.cpp index 27ba55f..c943c48 100644 --- a/src/kernel/kernel.cpp +++ b/src/kernel/kernel.cpp @@ -219,11 +219,10 @@ void QKernel::loadConfig(const char * fname) */ void QKernel::on_actionExecute_triggered() { - int i; QString s = QFileDialog::getOpenFileName(this, "Execute", progdir, "*.log"); if (!s.isNull()) { - i = s.indexOf(".log"); + int i = s.indexOf(".log"); if (i > 0) s.remove(i, 4); @@ -528,18 +527,21 @@ void QKernel::on_actionKill_triggered() KillInterpreterDialog dialog(this); dialog.setWindowTitle("Kill interpreter"); - MESSAGE m; - InterpEntry *interpreter; - if (dialog.exec()) { + MESSAGE m; m.msg_type = MSG_INT; m.param.pword[0] = INT_KILL; + + InterpEntry *interpreter; interpreter = findINTbyID(dialog.getInterpreterId()); + if (interpreter != NULL) { - if (!(interpreter->remote)) + if (!(interpreter->remote)) { write(interpreter->sock, &m, sizeof(MESSAGE)); - else + } + else { WriteMessage("This is a remote instance of a program!"); + } } else { WriteMessage("Interpreter not found"); @@ -556,11 +558,12 @@ void QKernel::NetMessage() /* TODO: It has to be rewritten */ MESSAGE msg; int cnt; - char ss[255]; InterpEntry *pom; cnt = read(net_sock, &msg, sizeof(MESSAGE)); if ((cnt > 0) && (msg.msg_type == MSG_NET)) { + char ss[255]; + switch(msg.param.pword[0]) { case NET_CSWRITELN: WriteMessage(msg.param.pstr); @@ -1002,7 +1005,6 @@ InterpEntry *QKernel::RunIntModule(char *ss, int r) void QKernel::RemoteInstance(InterpEntry *interp, int on) { MESSAGE m; - char s[255]; m.msg_type = MSG_NET; m.param.pword[0] = NET_NODE_EXIST; @@ -1057,6 +1059,7 @@ void QKernel::RemoteInstance(InterpEntry *interp, int on) m.param.pword[1] = interp->RInstances[on]; write(interp->sock, &m, sizeof(MESSAGE)); } else { /* There is no such a node! */ + char s[255]; sprintf(s, "Warning: Node number %d not found!", on); WriteMessage(s); WriteMessage("Allocating O-process on the local node");