[GCC] Warning-i podczas kompilacji

0

Witam wszystkich.
Znalazlem pewien kod w necie, jest dosc stary (napisany chyba w 94 r) i podczas kompilacji pokazuja mi sie kilka ostrzezen. Czesc nich sie juz pozbylem ale zostalo mi pare i nie wiem jak mam je usunac gdyz nie pisze w C tylko w Javie.

test.c: In function 'parse':
test.c warning: assignment makes integer from pointer without a cast
test.c warning: passing argument 2 of 'strcmp' makes pointer from intege r without a cast
test.c: In function 'Java_login_exit':
test.c warning: initialization makes integer from pointer without a cast
test.c warning: passing argument 2 of 'strcat' makes pointer from intege

#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <jni.h>
#include "login.h"

int getChars() {
	
  struct termios oldt, newt;
	  
  int ch;
  
  tcgetattr( STDIN_FILENO, &oldt );
  
  newt = oldt;
  
  newt.c_lflag &= ~( ICANON | ECHO );
  
  tcsetattr( STDIN_FILENO, TCSANOW, &newt );
  
  ch = getchar();
  
  tcsetattr( STDIN_FILENO, TCSANOW, &oldt );
  
  return ch;
  
}

void parse(char *buf,char **args)
{
    while (strcmp(buf,NULL) == 0) {

        while ((*buf == ' ') || (*buf == '\t'))
            *buf++ = NULL;

        *args++ = buf;

        while ((strcmp(buf,NULL) == 0) && (strcmp(buf,"") == 0) && (strcmp(buf,'\t') == 0))
            buf++;
    }

    *args = NULL;
}

void execute(char **args)
{
    int pid, status;

    if ((pid = fork()) < 0) {
        perror("fork");
        exit(1);

    }


    if (pid == 0) {
        execvp(*args, args);
        perror(*args);
        exit(1);
	}

    while (wait(&status) != pid)
        ;
}


 JNIEXPORT void JNICALL 
 Java_login_exit(JNIEnv *env, jobject obj,jstring login)
 {
	char log = (*env)->GetStringUTFChars(env, login, 0);

	char buf[1024] = "ls";
	strcat(buf,log);

	char *args[64];

        parse(buf, args);

        execute(args);

 }
 
 JNIEXPORT int JNICALL 
 Java_login_getch(JNIEnv *env, jobject obj)
 {

     return getChars();
 }
 
0
void parse(char *buf,char **args)
{
    while (strcmp(buf,NULL) == 0) {

        while ((*buf == ' ') || (*buf == '\t'))
            *buf++ = 0; // assignment makes integer from pointer without a cast

        *args++ = buf;

        while (
         (strcmp(buf,NULL) == 0) &&  // ekhm a eta szto ?
         (strcmp(buf,"") == 0) && // rownie mocne :>
         (strcmp(buf,"\t") == 0)) // passing argument 2 of 'strcmp' makes pointer from intege r without a cast
            buf++;
    }
    // imo ta petla jest jakas dziwna zastanow sie nad strncmp
    // albo nad porownaniem znaku (tak jak sie porownuje komorke tablicy integerow)

    *args = NULL;
}


 JNIEXPORT void JNICALL 
 Java_login_exit(JNIEnv *env, jobject obj,jstring login)
 {
	char* log = (*env)->GetStringUTFChars(env, login, 0); // initialization makes integer from pointer without a cast
        // tu bym sie zastanowil nad char log[ilestam]+strcpy
        // jesli bufor nie jest statyczny

	char buf[1024] = "ls";
	strcat(buf,log); // passing argument 2 of 'strcat' makes pointer from integer
        // ten warning sam zniknie.

	char *args[64];

        parse(buf, args);

        execute(args);

 }
 

co do:

while ( (strcmp(buf,NULL) == 0) &&  (strcmp(buf,"") == 0) && (strcmp(buf,"\t") == 0)) buf++;

Warunki petli skomentuje osobno na zewnatrz : drugi i trzeci wzajemnie sie wykluczaja, zas pierwszy to proszenie sie o naruszenie ochrony pamieci. Az sie cisnie na usta 'Co autor k***a mial na mysli ?' 'Dziady' Mickiewicza są bardziej spojne. Wiec napisz prosze czego po programie oczekujesz, bo obawiam sie, ze ten nie podola.

// topik nie leci do newbie z powodów: malo tu watkow o programowaniu pod nixy, a jeszcze mniej z pogranicza c i javy(scriptu ??)

1 użytkowników online, w tym zalogowanych: 0, gości: 1