[axel-devel] INT_MAX should not be used with long long
Emir Habul
emiraga at gmail.com
Wed Jan 12 20:13:45 UTC 2011
diff --git a/axel.c b/axel.c
index 84364cd..9ca69c8 100644
--- a/axel.c
+++ b/axel.c
@@ -120,7 +120,7 @@ axel_t *axel_new( conf_t *conf, int count, void *url )
}
s = conn_url( axel->conn );
strncpy( axel->url->text, s, MAX_STRING );
- if( ( axel->size = axel->conn[0].size ) != INT_MAX )
+ if( ( axel->size = axel->conn[0].size ) != LLONG_MAX )
{
if( axel->conf->verbose > 0 )
axel_message( axel, _("File size: %lld bytes"), axel->size );
@@ -326,7 +326,7 @@ void axel_do( axel_t *axel )
if( axel->conf->verbose )
{
/* Only abnormal behaviour if: */
- if( axel->conn[i].currentbyte < axel->conn[i].lastbyte &&
axel->size != INT_MAX )
+ if( axel->conn[i].currentbyte < axel->conn[i].lastbyte &&
axel->size != LLONG_MAX )
{
axel_message( axel, _("Connection %i unexpectedly closed"), i );
}
diff --git a/axel.h b/axel.h
index f6ebfe8..d03a940 100644
--- a/axel.h
+++ b/axel.h
@@ -89,6 +89,10 @@ typedef message_t if_t;
#define min( a, b ) ( (a) < (b) ? (a) : (b) )
#define max( a, b ) ( (a) > (b) ? (a) : (b) )
+#ifndef LLONG_MAX
+#define LLONG_MAX ((~0ULL) >> 1)
+#endif
+
typedef struct
{
conn_t *conn;
diff --git a/conn.c b/conn.c
index 202bcaf..d41ad32 100644
--- a/conn.c
+++ b/conn.c
@@ -307,7 +307,7 @@ int conn_info( conn_t *conn )
if( conn->size == -1 )
return( 0 );
else if( conn->size == -2 )
- conn->size = INT_MAX;
+ conn->size = LLONG_MAX;
}
else
{
@@ -359,7 +359,7 @@ int conn_info( conn_t *conn )
else if( conn->http->status == 200 || conn->http->status == 206 )
{
conn->supported = 0;
- conn->size = INT_MAX;
+ conn->size = LLONG_MAX;
}
else
{
More information about the axel-devel
mailing list