[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Warning reported by gcc-4.4.1


Keisial wrote:
Dmitry V. Krivenok wrote:
Hello!

gcc-4.4.1 reports one warning during compilation of libssh.
Attached patch fixes the problem.

Did you check that it is indeed not used uninitialized?

Suppose that the code was:

SFTP_SESSION *sftp;

if (rand()%100==1)
  sftp->shuffle()


Simply initializing sftp to NULL wouldn't solve too much...

Hi!

I did it just to avoid compiler warning :)
I assumed that the rest of the function is correct.

OK, lets look at the function:

/////////////////////////////////////////////////////
SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file) {
 STATUS_MESSAGE *status = NULL;
 SFTP_MESSAGE *msg = NULL;
 SFTP_SESSION *sftp = NULL;
 ssh_string ext;
 ssh_buffer buffer;
 uint32_t id;

 if (sftp == NULL || file == NULL) {
   return NULL;
 }
 sftp = file->sftp;
...
...
/////////////////////////////////////////////////////

It seems that author meant

/////////////////////////////////////////////////////
SFTP_STATVFS *sftp_fstatvfs(SFTP_FILE *file) {
 STATUS_MESSAGE *status = NULL;
 SFTP_MESSAGE *msg = NULL;
 SFTP_SESSION *sftp = NULL;
 ssh_string ext;
 ssh_buffer buffer;
 uint32_t id;

 if (file == NULL) {
   return NULL;
 }

 sftp = file->sftp;

 if (sftp == NULL) {
   return NULL;
 }
...
...
/////////////////////////////////////////////////////

Am I right?

--
Sincerely yours, Dmitry V. Krivenok
Orange System Co., Ltd.
Saint-Petersburg, Russia
work phone: +7 812 332-32-40
cellular phone: +7 921 576-70-91
e-mail: krivenok@xxxxxxxxxxxxxxx
web: http://www.orangesystem.ru
skype: krivenok_dmitry
jabber: krivenok_dmitry@xxxxxxxxx
icq: 242-526-443


References:
Warning reported by gcc-4.4.1"Dmitry V. Krivenok" <krivenok@xxxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org