Skip to content

Commit

Permalink
Merge pull request #387 from jmalak/cleanup-1
Browse files Browse the repository at this point in the history
cleanup code for assignment in expression to be more transparent
  • Loading branch information
davidrg authored Oct 28, 2024
2 parents 0476ff7 + 02cb0dd commit e8b31fc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 16 deletions.
18 changes: 9 additions & 9 deletions kermit/dialer/kconnect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ kcopy(char *source, char *destination) {

x = strlen(destination);
len = strlen(destination) + strlen(source) + 2;
if (!(p = (char *)malloc(len)))
if ((p = (char *)malloc(len)) == NULL)
return(-1);
strcpy(p,destination); /* Directory part */
if (!ISDIRSEP(*(destination+x-1))) /* Separator, if needed */
Expand All @@ -296,7 +296,7 @@ kcopy(char *source, char *destination) {
strcat(p,q); /* Concatenate to new directory */
} else {
len = strlen(destination) + 64;
if (!(p = (char *)malloc(len)))
if ((p = (char *)malloc(len)) == NULL)
return(-1);
strcpy(p,destination);
}
Expand Down Expand Up @@ -332,7 +332,7 @@ kmkdir(const char *path) {
x = strlen(path);
if (x < 1 || x > CKMAXPATH) /* Check length */
return(-1);
if (!(tp = (char *)malloc(x+1))) /* Make a temporary copy */
if ((tp = (char *)malloc(x+1)) == NULL) /* Make a temporary copy */
return(-1);
strcpy(tp,path);

Expand Down Expand Up @@ -735,7 +735,7 @@ K_CONNECTOR::K_CONNECTOR(void)
if ( !isdir(dir) ) {
kmkdir(dir);

if ( common = GetAppData(1) ) {
if ( (common = GetAppData(1)) != NULL ) {
sprintf(file,"%s%s",(char *)common, "Kermit 95\\K95CUSTOM.INI");
kcopy(file,dir);
appdata = GetAppData(0);
Expand Down Expand Up @@ -7227,7 +7227,7 @@ StartKermit( KD_LIST_ITEM * entry, KD_CONFIG * config, KD_LIST_ITEM * def_entry
}

if (!StartKermitFileName &&
!(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE])) {
(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE]) == NULL) {

if ( !StartKermitFileName )
OutofMemory("Unable to create MESSAGE_WINDOW StartKermit 3");
Expand Down Expand Up @@ -8403,7 +8403,7 @@ ExportLocations(void)
}

if (!StartKermitFileName &&
!(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE])) {
(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE]) == NULL) {
if ( !StartKermitFileName )
OutofMemory("Unable to create ICHAR ExportLocations 1");

Expand Down Expand Up @@ -8511,7 +8511,7 @@ ExportModems(void)
}

if (!StartKermitFileName &&
!(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE])) {
(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE]) == NULL) {
if ( !StartKermitFileName )
OutofMemory("Unable to create ICHAR ExportModems");
#ifdef WIN32
Expand Down Expand Up @@ -8669,7 +8669,7 @@ CreateShortcut( KD_LIST_ITEM * entry, KD_CONFIG * config, KD_LIST_ITEM * def_ent
}

if (!StartKermitFileName &&
!(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE])) {
(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE]) == NULL) {
if ( !StartKermitFileName )
OutofMemory("Unable to create ICHAR CreateShortcut");
#ifdef WIN32
Expand Down Expand Up @@ -8945,7 +8945,7 @@ CreateScriptFile( KD_LIST_ITEM * entry, KD_CONFIG * config, KD_LIST_ITEM * def_e
}

if (!StartKermitFileName &&
!(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE])) {
(StartKermitFileName = (ZIL_ICHAR *) new ZIL_ICHAR[BUFFERSIZE]) == NULL) {
if ( !StartKermitFileName )
OutofMemory("Unable to create ICHAR CreateScriptFile");
#ifdef WIN32
Expand Down
2 changes: 1 addition & 1 deletion kermit/dialer/kquick.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void K_QUICK::PopulateList( enum TRANSPORT type )
UIW_COMBO_BOX * combo = (UIW_COMBO_BOX *) Get( COMBO_QUICK );
UIW_VT_LIST * quicklist = (UIW_VT_LIST *) Get( LIST_QUICK );
UIW_BUTTON * button = NULL;
while ( button = (UIW_BUTTON *) quicklist->First() ) {
while ( (button = (UIW_BUTTON *)quicklist->First()) != NULL ) {
*quicklist - button;
delete button;
}
Expand Down
4 changes: 2 additions & 2 deletions kermit/dialer/ksetgeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ InitTCPProtoList()
{
UIW_BUTTON * button;
UIW_VT_LIST * list = (UIW_VT_LIST *) Get( LIST_TCP_PROTOCOL ) ;
while ( button = (UIW_BUTTON *) list->First() ) {
while ( (button = (UIW_BUTTON *)list->First()) != NULL ) {
*list - button;
delete button;
}
Expand Down Expand Up @@ -995,7 +995,7 @@ InitSSHProtoList()
{
UIW_BUTTON * button;
UIW_VT_LIST * list = (UIW_VT_LIST *) Get( LIST_TCP_PROTOCOL ) ;
while ( button = (UIW_BUTTON *) list->First() ) {
while ( (button = (UIW_BUTTON *)list->First()) != NULL ) {
*list - button;
delete button;
}
Expand Down
6 changes: 5 additions & 1 deletion kermit/dialer/ksetprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@
extern "C" {
#include "ckcdeb.h" /* Typedefs, debug formats, etc */
#include "ckucmd.h"
#ifdef printf
#undef printf
#endif
#ifdef fprintf
#undef fprintf
#endif
#include <windows.h> /* Windows Definitions */
}
#endif /* WIN32 */
Expand Down Expand Up @@ -809,7 +813,7 @@ Win32EnumPrt( struct keytab ** pTable, struct keytab ** pTable2, int * pN )
// (simple error checking, if these work assume rest will too)
//

if (!(pPrtInfo2 = (LPPRINTER_INFO_2) LocalAlloc (LPTR, dwBytesNeeded)))
if ((pPrtInfo2 = (LPPRINTER_INFO_2)LocalAlloc (LPTR, dwBytesNeeded)) == NULL)
{
return(FALSE);
}
Expand Down
6 changes: 3 additions & 3 deletions kermit/dialer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#include "kwinmgr.hpp"
#ifdef WIN32
extern "C" {
#define OS2
#define NT
//#define OS2
//#define NT
#include "ckcdeb.h"
#include "ckoetc.h"
#ifndef NODIAL
Expand Down Expand Up @@ -278,7 +278,7 @@ int UI_APPLICATION::Main(void)
#ifdef WIN32
#ifndef NODIAL
printf("Checking TAPI\n");
if (TapiAvail = cktapiinit(hInstance)) {
if ((TapiAvail = cktapiinit(hInstance)) != 0) {
printf("TAPI available\n");
cktapiopen();
printf("TAPI Open\n");
Expand Down

0 comments on commit e8b31fc

Please sign in to comment.