Jump to content
  • 0

Gcc10 Compile Warning


Defacer35

Question

- SOLVED -

 

Update system_cmd to 512 and char name to 128 thats solve the warning.

 

- SOLVED -

 

 

1d7b6c3581eb254f945b60d9a7a85094.png

 

Hello devs, i have a little trouble here.

 

name veriable has a char* but i have this warn what should i do ? Best regards..

 

void log_file_delete_old (const char* filename)
{
	struct stat sb;
	int num1, num2;
	char buf[32];
	char system_cmd[64];
	struct tm new_tm;

	if (stat(filename, &sb) == -1)
	{
		perror("log_file_delete_old: stat");
		return;
	}

	if (!S_ISDIR(sb.st_mode))
	{
		return;
	}

	new_tm = *tm_calc(NULL, -log_keep_days);
	sprintf (buf, "%04d%02d%02d", new_tm.tm_year + 1900, new_tm.tm_mon + 1, new_tm.tm_mday);
	num1 = atoi(buf);

	struct dirent** namelist;
	int n;

	n = scandir (filename, &namelist, 0, alphasort);

	if (n < 0)
	{
		perror ("scandir");
	}
	else
	{
		char name[MAXNAMLEN + 1];

		while (n-- > 0)
		{
			strncpy (name, namelist[n]->d_name, 255);
			name[255] = '\0';

			free (namelist[n]);

			if (*name == '.')
			{
				continue;
			}

			if (!isdigit (*name))
			{
				continue;
			}

			num2 = atoi (name);

			if (num2 <= num1)
			{
				sprintf (system_cmd, "rm -rf %s/%s", filename, name);
				system (system_cmd);

				sys_log (0, "%s: SYSTEM_CMD: %s", __FUNCTION__, system_cmd);
				fprintf (stderr, "%s: SYSTEM_CMD: %s %s:%d %s:%d\n", __FUNCTION__, system_cmd, buf, num1, name, num2);
			}
		}
	}

		free (namelist);
}

 

Edited by Defacer35
Solved (see edit history)
Link to post

6 answers to this question

Recommended Posts

  • 0
  • VIP
1 hour ago, Defacer35 said:

041001feee4b1aa2a62de45501c567ab.png

 

First of all thanks for the answer, does that before but i have same warn again 😕

Can you please post the whole file on pastebin so we can check lines and functions.

 

You show us void log_file_delete_old (const char* filename) but seems different in the compiler.

Need log_file_rotate() too

  • Love 1
Link to post
  • 0
15 minutes ago, WeedHex said:

Change:

char name[MAXNAMLEN + 1];

to

char name[512];

 

 

char dir[128];

to

char dir[256];

 

Idk why you're getting these warning, need other infos btw try to do what compiler said upgrading the sizes.

 

Sadly i try this before this not the problem i think i'm try char name 2048 or 1024 or 512 or 256 also 64 - 128 getting same warn every time, i'm search almost every stackflow post but nothing get anything..

 

Btw thanks for your effort.

  • Love 1
Link to post
Guest
This topic is now closed to further replies.


  • Recently Browsing

    No registered users viewing this page.

  • Activity

    1. 7

      mobs/stone drop by level ?

    2. 31

      Metin2 Download Center - Backup Status

    3. 2

      Christmas 2020

    4. 0

      Weird Cryptopp Problem

    5. 0

      Hello i have error with skill!

    6. 1

      Gurgarath Sus

    7. 24
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.