summaryrefslogtreecommitdiff
path: root/libgammu/phone
diff options
context:
space:
mode:
Diffstat (limited to 'libgammu/phone')
-rw-r--r--libgammu/phone/alcatel/alcatel.c10
-rw-r--r--libgammu/phone/at/at-sms.c27
-rw-r--r--libgammu/phone/at/atgen.c33
-rw-r--r--libgammu/phone/atobex/atobex.c7
-rw-r--r--libgammu/phone/dummy/dummy.c77
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/6510file.c24
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/6510file.h4
-rw-r--r--libgammu/phone/nokia/dct4s40/6510/n6510.c49
-rw-r--r--libgammu/phone/nokia/wd2/n3650.c2
-rw-r--r--libgammu/phone/obex/mobex.c3
-rw-r--r--libgammu/phone/obex/obexfunc.h6
-rw-r--r--libgammu/phone/obex/obexgen.c19
-rw-r--r--libgammu/phone/pfunc.c3
13 files changed, 163 insertions, 101 deletions
diff --git a/libgammu/phone/alcatel/alcatel.c b/libgammu/phone/alcatel/alcatel.c
index a77994f..9ad9b44 100644
--- a/libgammu/phone/alcatel/alcatel.c
+++ b/libgammu/phone/alcatel/alcatel.c
@@ -847,7 +847,7 @@ static void ALCATEL_DecodeString(GSM_StateMachine *s, unsigned const char *buffe
len = buffer[0];
if (Priv->ProtocolVersion == V_1_1 && (buffer[1] == ALCATEL_UNICODE_FLAG)) {
/* UCS-2-BE string */
- if (GSM_PHONEBOOK_TEXT_LENGTH < len/2) {
+ if (GSM_PHONEBOOK_TEXT_LENGTH <= len / 2) {
smprintf(s, "WARNING: Text truncated, to %d from %d\n", maxlen, len/2 + 1);
len = GSM_PHONEBOOK_TEXT_LENGTH * 2;
}
@@ -856,7 +856,7 @@ static void ALCATEL_DecodeString(GSM_StateMachine *s, unsigned const char *buffe
Priv->ReturnString[len + 2] = 0;
} else {
/* Alcatel alphabet string */
- if (GSM_PHONEBOOK_TEXT_LENGTH < len) {
+ if (GSM_PHONEBOOK_TEXT_LENGTH <= len) {
smprintf(s, "WARNING: Text truncated, to %d from %d\n", maxlen, len + 1);
len = GSM_PHONEBOOK_TEXT_LENGTH;
}
@@ -2066,11 +2066,13 @@ static GSM_Error ALCATEL_SetMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
break;
case PBK_Text_LastName:
UpdatedFields[0] = TRUE;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = TRUE;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 0, entry->Entries[i].Text)) != ERR_NONE) return error;
+ NameSet = TRUE;
break;
case PBK_Text_FirstName:
UpdatedFields[1] = TRUE;
- if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error; NameSet = TRUE;
+ if ((error = ALCATEL_UpdateField(s, Alcatel_string, entry->Location, 1, entry->Entries[i].Text)) != ERR_NONE) return error;
+ NameSet = TRUE;
break;
case PBK_Text_Company:
UpdatedFields[2] = TRUE;
diff --git a/libgammu/phone/at/at-sms.c b/libgammu/phone/at/at-sms.c
index 12d071b..0cd0d65 100644
--- a/libgammu/phone/at/at-sms.c
+++ b/libgammu/phone/at/at-sms.c
@@ -408,7 +408,7 @@ GSM_Error ATGEN_GetSMSLocation(GSM_StateMachine *s, GSM_SMSMessage *sms, unsigne
(*location)--;
}
smprintf(s, "SMS folder %i & location %i -> ATGEN folder %i & location %i\n",
- sms->Folder,sms->Location,*folderid,*location);
+ sms->Folder, sms->Location, *folderid, *location);
/* Set the needed memory type */
if (Priv->SIMSMSMemory == AT_AVAILABLE &&
@@ -1534,7 +1534,6 @@ GSM_Error ATGEN_ReplyAddSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
GSM_Error error;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
size_t i = 0;
- int folder = 0;
switch (Priv->ReplyState) {
case AT_Reply_SMSEdit:
@@ -1564,11 +1563,13 @@ GSM_Error ATGEN_ReplyAddSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
smprintf(s, "Saved at AT location %i\n",
s->Phone.Data.SaveSMSMessage->Location);
/* Adjust location */
- folder = s->Phone.Data.SaveSMSMessage->Folder;
- ATGEN_SetSMSLocation(s, s->Phone.Data.SaveSMSMessage,
- (folder / 2), /* We care only about SIM/Phone */
- s->Phone.Data.SaveSMSMessage->Location);
- s->Phone.Data.SaveSMSMessage->Folder = folder;
+ ATGEN_SetSMSLocation(
+ s,
+ s->Phone.Data.SaveSMSMessage,
+ /* We care only about SIM/Phone */
+ s->Phone.Data.SaveSMSMessage->Folder <= 2 ? 1 : 2,
+ s->Phone.Data.SaveSMSMessage->Location
+ );
return ERR_NONE;
case AT_Reply_Error:
smprintf(s, "Error\n");
@@ -1584,7 +1585,7 @@ GSM_Error ATGEN_ReplyAddSMSMessage(GSM_Protocol_Message *msg, GSM_StateMachine *
return ERR_UNKNOWNRESPONSE;
}
-GSM_Error ATGEN_MakeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *message, unsigned char *hexreq, int *current, size_t *length2)
+GSM_Error ATGEN_MakeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *message, unsigned char *hexreq, size_t hexlength, int *current, size_t *length2)
{
GSM_Error error;
GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
@@ -1708,7 +1709,7 @@ GSM_Error ATGEN_MakeSMSFrame(GSM_StateMachine *s, GSM_SMSMessage *message, unsig
/* If not SMS with UDH, it's as normal text */
if (message->UDH.Type == UDH_NoUDH) {
error = ATGEN_EncodeText(
- s, message->Text, UnicodeLength(message->Text), hexreq, sizeof(hexreq), length2
+ s, message->Text, UnicodeLength(message->Text), hexreq, hexlength, length2
);
if (error != ERR_NONE) {
return error;
@@ -1783,7 +1784,7 @@ GSM_Error ATGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
}
/* Format SMS frame */
- error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &length);
+ error = ATGEN_MakeSMSFrame(s, sms, hexreq, sizeof(hexreq), &current, &length);
if (error != ERR_NONE) {
return error;
@@ -1803,7 +1804,7 @@ GSM_Error ATGEN_AddSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
/* No (good and 100% working) support for alphanumeric numbers */
if (sms->Number[1]!='+' && (sms->Number[1]<'0' || sms->Number[1]>'9')) {
EncodeUnicode(sms->Number,"123",3);
- error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &length);
+ error = ATGEN_MakeSMSFrame(s, sms, hexreq, sizeof(hexreq), &current, &length);
if (error != ERR_NONE) return error;
}
}
@@ -1960,7 +1961,7 @@ GSM_Error ATGEN_SendSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
if (sms->PDU == SMS_Deliver) {
sms->PDU = SMS_Submit;
}
- error = ATGEN_MakeSMSFrame(s, sms, hexreq, &current, &length);
+ error = ATGEN_MakeSMSFrame(s, sms, hexreq, sizeof(hexreq), &current, &length);
if (error != ERR_NONE) {
return error;
@@ -2422,6 +2423,7 @@ int *GetRange(GSM_StateMachine *s, const char *buffer)
/* Did we parse anything? */
if (endptr == chr) {
smprintf(s, "Failed to find number in range!\n");
+ free(result);
return NULL;
}
/* Allocate more memory if needed */
@@ -2457,6 +2459,7 @@ int *GetRange(GSM_StateMachine *s, const char *buffer)
break;
} else if (*chr != ',') {
smprintf(s, "Bad character in range: %c\n", *chr);
+ free(result);
return NULL;
}
}
diff --git a/libgammu/phone/at/atgen.c b/libgammu/phone/at/atgen.c
index c1b65ca..067f5d4 100644
--- a/libgammu/phone/at/atgen.c
+++ b/libgammu/phone/at/atgen.c
@@ -437,7 +437,7 @@ GSM_Error ATGEN_WaitFor(GSM_StateMachine *s, const char * cmd, size_t len,
*
* \return True when text does not contain non hex chars.
*/
-INLINE gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
+gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
{
size_t i = 0;
@@ -456,7 +456,7 @@ INLINE gboolean ATGEN_HasOnlyHexChars(const char *text, const size_t length)
*
* \return True when text does not contain non digits chars.
*/
-INLINE gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
+gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
{
size_t i = 0;
@@ -476,7 +476,7 @@ INLINE gboolean ATGEN_HasOnlyDigits(const char *text, const size_t length)
* \param text Text.
* \return True when text can be UCS2.
*/
-INLINE gboolean ATGEN_IsUCS2(const char *text, const size_t length)
+gboolean ATGEN_IsUCS2(const char *text, const size_t length)
{
return (length > 3) &&
(length % 4 == 0) &&
@@ -491,7 +491,7 @@ INLINE gboolean ATGEN_IsUCS2(const char *text, const size_t length)
* \param text Text.
* \return True when text can be HEX.
*/
-INLINE gboolean ATGEN_IsHex(const char *text, const size_t length)
+gboolean ATGEN_IsHex(const char *text, const size_t length)
{
return (length > 4) &&
(length % 2 == 0) &&
@@ -506,7 +506,7 @@ INLINE gboolean ATGEN_IsHex(const char *text, const size_t length)
* \param text Text.
* \return True when text can be HEX.
*/
-INLINE gboolean ATGEN_IsNumber(const char *text, const size_t length)
+gboolean ATGEN_IsNumber(const char *text, const size_t length)
{
return ATGEN_HasOnlyDigits(text, length);
}
@@ -759,7 +759,10 @@ GSM_Error ATGEN_DecodeText(GSM_StateMachine *s,
return ERR_MOREMEMORY;
}
DecodeHexBin(buffer, input, length);
- if (2 * strlen(buffer) >= outlength) return ERR_MOREMEMORY;
+ if (2 * strlen(buffer) >= outlength) {
+ free(buffer);
+ return ERR_MOREMEMORY;
+ }
DecodeDefault(output, buffer, strlen(buffer), TRUE, NULL);
free(buffer);
buffer = NULL;
@@ -1613,6 +1616,7 @@ GSM_Error ATGEN_SQWEReply(GSM_Protocol_Message *msg UNUSED, GSM_StateMachine *s)
GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
{
+ GSM_Phone_ATGENData *Priv = &s->Phone.Data.Priv.ATGEN;
GSM_USSDMessage ussd;
GSM_Error error;
unsigned char *pos = NULL;
@@ -1719,13 +1723,16 @@ GSM_Error ATGEN_ReplyGetUSSD(GSM_Protocol_Message *msg, GSM_StateMachine *s)
coding = GSM_GetMessageCoding(&(s->di), dcs);
}
- smprintf(s, "coding %d -> %d\n", dcs, coding);
+ smprintf(s, "USSD coding DCS = %d -> Coding = %d\n", dcs, coding);
if (coding == SMS_Coding_Default_No_Compression) {
- DecodeHexBin(packed, hex_encoded, strlen(hex_encoded));
- GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded);
- DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL);
-
+ if (Priv->Charset == AT_CHARSET_HEX || GSM_IsPhoneFeatureAvailable(s->Phone.Data.ModelInfo, F_ENCODED_USSD)) {
+ DecodeHexBin(packed, hex_encoded, strlen(hex_encoded));
+ GSM_UnpackEightBitsToSeven(0, strlen(hex_encoded), sizeof(decoded), packed, decoded);
+ DecodeDefault(ussd.Text, decoded, strlen(decoded), TRUE, NULL);
+ } else {
+ DecodeDefault(ussd.Text, hex_encoded, strlen(hex_encoded), TRUE, NULL);
+ }
} else if (coding == SMS_Coding_Unicode_No_Compression) {
DecodeHexUnicode(ussd.Text, hex_encoded + offset, strlen(hex_encoded));
} else if (coding == SMS_Coding_8bit) {
@@ -4766,7 +4773,7 @@ GSM_Error ATGEN_ReplyGetDivert(GSM_Protocol_Message *msg, GSM_StateMachine *s)
if (error != ERR_NONE) {
error = ATGEN_ParseReply(s, str,
- "+CCFC: @i, @i, @p, @I, @s, @i, @i",
+ "+CCFC: @i, @i, @p, @I, @s, @I, @I",
&status,
&class,
response->Entries[response->EntriesNum].Number,
@@ -6146,7 +6153,6 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReply, "AT+CLIP" ,0x00,0x00,ID_SetIncomingCall },
{ATGEN_GenericReply, "AT+CCWA" ,0x00,0x00,ID_SetIncomingCall },
{ATGEN_GenericReply, "AT+CUSD" ,0x00,0x00,ID_SetUSSD },
-{ATGEN_ReplyGetUSSD, "AT+CUSD" ,0x00,0x00,ID_GetUSSD },
{ATGEN_ReplyGetUSSD, "+CUSD" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReply, "AT+CLIP=1" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_ReplyIncomingCallInfo, "+CLIP" ,0x00,0x00,ID_IncomingFrame },
@@ -6205,6 +6211,7 @@ GSM_Reply_Function ATGENReplyFunctions[] = {
{ATGEN_GenericReplyIgnore, "^HCSQ:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "^SRVST:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "^SIMST:" ,0x00,0x00,ID_IncomingFrame },
+{ATGEN_GenericReplyIgnore, "^STIN:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+ZUSIMR:" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+ZEND" ,0x00,0x00,ID_IncomingFrame },
{ATGEN_GenericReplyIgnore, "+CDSI:" ,0x00,0x00,ID_IncomingFrame },
diff --git a/libgammu/phone/atobex/atobex.c b/libgammu/phone/atobex/atobex.c
index 9285d51..fcf0953 100644
--- a/libgammu/phone/atobex/atobex.c
+++ b/libgammu/phone/atobex/atobex.c
@@ -647,7 +647,7 @@ GSM_Error ATOBEX_SetBitmap(GSM_StateMachine *s, GSM_Bitmap *Bitmap)
* @{
*/
-GSM_Error ATOBEX_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error ATOBEX_AddFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_Error error;
@@ -658,7 +658,7 @@ GSM_Error ATOBEX_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int
return OBEXGEN_AddFilePart(s, File, Pos, Handle);
}
-GSM_Error ATOBEX_SendFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error ATOBEX_SendFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_Error error;
@@ -669,7 +669,7 @@ GSM_Error ATOBEX_SendFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int
return OBEXGEN_SendFilePart(s, File, Pos, Handle);
}
-GSM_Error ATOBEX_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size)
+GSM_Error ATOBEX_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size)
{
GSM_Error error;
@@ -1448,7 +1448,6 @@ GSM_Error ATOBEX_ReplyGetBatteryCharge(GSM_Protocol_Message *msg, GSM_StateMachi
bat->ChargeVoltage *= 10;
switch (method) {
case 0:
- bat->BatteryType = GSM_BatteryLiPol;
bat->BatteryType = GSM_BatteryNiMH;
break;
case 1:
diff --git a/libgammu/phone/dummy/dummy.c b/libgammu/phone/dummy/dummy.c
index 41a6cd7..778e682 100644
--- a/libgammu/phone/dummy/dummy.c
+++ b/libgammu/phone/dummy/dummy.c
@@ -57,10 +57,11 @@
#include <dirent.h>
#endif
-GSM_Error DUMMY_Error(GSM_StateMachine *s, const char *message)
+GSM_Error DUMMY_Error(GSM_StateMachine *s, const char *message, const char *path)
{
int tmp_errno;
tmp_errno = errno;
+ smprintf(s, "Filesystem path: %s\n", path);
GSM_OSErrorInfo(s, message);
if (tmp_errno == ENOENT) {
return ERR_EMPTY;
@@ -533,7 +534,7 @@ GSM_Error DUMMY_DeleteSMS(GSM_StateMachine *s, GSM_SMSMessage *sms)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "SMS unlink failed");
+ error = DUMMY_Error(s, "SMS unlink failed", filename);
}
free(filename);
filename=NULL;
@@ -994,7 +995,7 @@ GSM_Error DUMMY_DeleteAlarm(GSM_StateMachine *s, GSM_Alarm *entry)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "calendar unlink failed");
+ error = DUMMY_Error(s, "calendar unlink failed", filename);
}
free(filename);
@@ -1068,11 +1069,11 @@ GSM_Error DUMMY_GetWAPBookmark(GSM_StateMachine *s, GSM_WAPBookmark *bookmark)
{
switch (bookmark->Location) {
case 1:
- EncodeUnicode(bookmark->Address, "http://blog.cihar.com/", 22);
+ EncodeUnicode(bookmark->Address, "https://blog.cihar.com/", 23);
EncodeUnicode(bookmark->Title, "Michals weblog", 14);
return ERR_NONE;
case 2:
- EncodeUnicode(bookmark->Address, "http://wammu.eu/", 16);
+ EncodeUnicode(bookmark->Address, "https://wammu.eu/", 17);
EncodeUnicode(bookmark->Title, "Wammu website", 13);
return ERR_NONE;
default:
@@ -1097,7 +1098,7 @@ GSM_Error DUMMY_SetFileAttributes(GSM_StateMachine *s, GSM_File *File)
return ERR_NONE;
}
-GSM_Error DUMMY_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error DUMMY_AddFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
char *path;
FILE *file;
@@ -1118,21 +1119,21 @@ GSM_Error DUMMY_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *
file = fopen(path, "w");
if (file == NULL) {
+ error = DUMMY_Error(s, "fopen(w) failed", path);
free(path);
- error = DUMMY_Error(s, "fopen(w) failed");
if (error == ERR_EMPTY) return ERR_PERMISSION;
return error;
}
if (fwrite(File->Buffer, 1, File->Used, file) != File->Used) {
+ error = DUMMY_Error(s, "fwrite failed", path);
free(path);
- error = DUMMY_Error(s, "fwrite failed");
fclose(file);
if (error == ERR_EMPTY) return ERR_PERMISSION;
return error;
}
if (fclose(file) != 0) {
+ error = DUMMY_Error(s, "fclose failed", path);
free(path);
- error = DUMMY_Error(s, "fclose failed");
if (error == ERR_EMPTY) return ERR_PERMISSION;
return error;
}
@@ -1144,13 +1145,13 @@ GSM_Error DUMMY_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *
return ERR_EMPTY;
}
-GSM_Error DUMMY_SendFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error DUMMY_SendFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
EncodeUnicode(File->ID_FullName, "incoming/", 9);
return DUMMY_AddFilePart(s, File, Pos, Handle);
}
-GSM_Error DUMMY_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size)
+GSM_Error DUMMY_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size)
{
char *path, *name, *pos;
GSM_Error error;
@@ -1179,6 +1180,7 @@ GSM_Error DUMMY_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, in
GSM_Error DUMMY_GetFolderListing(GSM_StateMachine *s, GSM_File *File, gboolean start)
{
GSM_Phone_DUMMYData *Priv = &s->Phone.Data.Priv.DUMMY;
+ GSM_Error error;
char *path;
struct dirent *dp;
struct stat sb;
@@ -1191,12 +1193,15 @@ GSM_Error DUMMY_GetFolderListing(GSM_StateMachine *s, GSM_File *File, gboolean s
smprintf(s, "listing %s\n", path);
strcpy(Priv->dirnames[DUMMY_MAX_FS_DEPTH], path);
Priv->dir[DUMMY_MAX_FS_DEPTH] = opendir(path);
- free(path);
- path=NULL;
if (Priv->dir[DUMMY_MAX_FS_DEPTH] == NULL) {
- return DUMMY_Error(s, "opendir failed");
+ error = DUMMY_Error(s, "opendir failed", path);
+ free(path);
+ path=NULL;
+ return error;
}
+ free(path);
+ path=NULL;
}
read_next_entry:
@@ -1214,9 +1219,10 @@ read_next_entry:
/* Stat file */
path = DUMMY_GetFSPath(s, dp->d_name, DUMMY_MAX_FS_DEPTH);
if (stat(path, &sb) < 0) {
+ error = DUMMY_Error(s, "stat failed", path);
free(path);
path=NULL;
- return DUMMY_Error(s, "stat failed");
+ return error;
}
/* Fill file structure */
@@ -1247,9 +1253,10 @@ read_next_entry:
Priv->fs_depth++;
Priv->dir[Priv->fs_depth] = opendir(path);
if (Priv->dir[Priv->fs_depth] == NULL) {
+ error = DUMMY_Error(s, "nested opendir failed", path);
free(path);
path=NULL;
- return DUMMY_Error(s, "nested opendir failed");
+ return error;
}
strcpy(Priv->dirnames[Priv->fs_depth], path);
}
@@ -1261,6 +1268,7 @@ read_next_entry:
GSM_Error DUMMY_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, gboolean start)
{
GSM_Phone_DUMMYData *Priv = &s->Phone.Data.Priv.DUMMY;
+ GSM_Error error;
char *path;
struct dirent *dp;
struct stat sb;
@@ -1276,12 +1284,15 @@ GSM_Error DUMMY_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, gboolean
path = DUMMY_GetFilePath(s, "fs");
strcpy(Priv->dirnames[0], path);
Priv->dir[0] = opendir(path);
- free(path);
- path=NULL;
if (Priv->dir[0] == NULL) {
- return DUMMY_Error(s, "opendir failed");
+ error = DUMMY_Error(s, "opendir failed", path);
+ free(path);
+ path = NULL;
+ return error;
}
+ free(path);
+ path=NULL;
Priv->fs_depth = 0;
}
@@ -1302,9 +1313,10 @@ read_next_entry:
/* Stat file */
path = DUMMY_GetFSPath(s, dp->d_name, Priv->fs_depth);
if (stat(path, &sb) < 0) {
+ error = DUMMY_Error(s, "stat failed", path);
free(path);
- path=NULL;
- return DUMMY_Error(s, "stat failed");
+ path = NULL;
+ return error;
}
/* Fill file structure */
@@ -1335,9 +1347,10 @@ read_next_entry:
Priv->fs_depth++;
Priv->dir[Priv->fs_depth] = opendir(path);
if (Priv->dir[Priv->fs_depth] == NULL) {
+ error = DUMMY_Error(s, "nested opendir failed", path);
free(path);
path=NULL;
- return DUMMY_Error(s, "nested opendir failed");
+ return error;
}
strcpy(Priv->dirnames[Priv->fs_depth], path);
}
@@ -1353,9 +1366,9 @@ GSM_Error DUMMY_DeleteFile(GSM_StateMachine *s, unsigned char *ID)
path = DUMMY_GetFSFilePath(s, ID);
if (unlink(path) != 0) {
+ error = DUMMY_Error(s, "unlink failed", path);
free(path);
- path=NULL;
- error = DUMMY_Error(s, "unlink failed");
+ path = NULL;
if (error == ERR_EMPTY) return ERR_FILENOTEXIST;
return error;
}
@@ -1372,9 +1385,9 @@ GSM_Error DUMMY_DeleteFolder(GSM_StateMachine *s, unsigned char *ID)
path = DUMMY_GetFSFilePath(s, ID);
smprintf(s, "Deleting directory %s\n", path);
if (rmdir(path) != 0) {
+ error = DUMMY_Error(s, "rmdir failed", path);
free(path);
- path=NULL;
- error = DUMMY_Error(s, "rmdir failed");
+ path = NULL;
if (error == ERR_EMPTY) return ERR_FILENOTEXIST;
return error;
}
@@ -1387,6 +1400,7 @@ GSM_Error DUMMY_AddFolder(GSM_StateMachine *s, GSM_File *File)
{
char *path;
size_t pos;
+ GSM_Error error;
pos = UnicodeLength(File->ID_FullName);
if (pos > 0 && (File->ID_FullName[2*pos - 2] != 0 || File->ID_FullName[2*pos - 1] != '/')) {
@@ -1398,9 +1412,10 @@ GSM_Error DUMMY_AddFolder(GSM_StateMachine *s, GSM_File *File)
path = DUMMY_GetFSFilePath(s, File->ID_FullName);
if (MKDIR(path) != 0) {
+ error = DUMMY_Error(s, "mkdir failed", path);
free(path);
path=NULL;
- return DUMMY_Error(s, "mkdir failed");
+ return error;
}
free(path);
path=NULL;
@@ -1492,7 +1507,7 @@ GSM_Error DUMMY_DeleteMemory(GSM_StateMachine *s, GSM_MemoryEntry *entry)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "memory unlink failed");
+ error = DUMMY_Error(s, "memory unlink failed", filename);
}
free(filename);
@@ -1603,7 +1618,7 @@ GSM_Error DUMMY_DeleteToDo(GSM_StateMachine *s, GSM_ToDoEntry *entry)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "todo unlink failed");
+ error = DUMMY_Error(s, "todo unlink failed", filename);
}
free(filename);
@@ -1707,7 +1722,7 @@ GSM_Error DUMMY_DeleteCalendar(GSM_StateMachine *s, GSM_CalendarEntry *entry)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "calendar unlink failed");
+ error = DUMMY_Error(s, "calendar unlink failed", filename);
}
free(filename);
@@ -1823,7 +1838,7 @@ GSM_Error DUMMY_DeleteNote(GSM_StateMachine *s, GSM_NoteEntry *entry)
if (unlink(filename) == 0) {
error = ERR_NONE;
} else {
- error = DUMMY_Error(s, "note unlink failed");
+ error = DUMMY_Error(s, "note unlink failed", filename);
}
free(filename);
filename=NULL;
diff --git a/libgammu/phone/nokia/dct4s40/6510/6510file.c b/libgammu/phone/nokia/dct4s40/6510/6510file.c
index 66eba04..fa59ea5 100644
--- a/libgammu/phone/nokia/dct4s40/6510/6510file.c
+++ b/libgammu/phone/nokia/dct4s40/6510/6510file.c
@@ -379,7 +379,7 @@ static GSM_Error N6510_GetFileSystemStatus1(GSM_StateMachine *s, GSM_FileSystemS
return GSM_WaitFor (s, req, 10, 0x6D, 4, ID_FileSystemStatus);
}
-static GSM_Error N6510_GetFilePart1(GSM_StateMachine *s, GSM_File *File, int *Handle UNUSED, int *Size)
+static GSM_Error N6510_GetFilePart1(GSM_StateMachine *s, GSM_File *File, int *Handle UNUSED, size_t *Size)
{
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
int old;
@@ -564,7 +564,7 @@ GSM_Error N6510_ReplyAddFilePart1(GSM_Protocol_Message *msg UNUSED, GSM_StateMac
return ERR_NONE;
}
-static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle UNUSED)
+static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle UNUSED)
{
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
GSM_File File2;
@@ -642,7 +642,7 @@ static GSM_Error N6510_AddFilePart1(GSM_StateMachine *s, GSM_File *File, int *Po
Add[12] = j / 256;
Add[13] = j % 256;
memcpy(Add+14,File->Buffer+(*Pos),j);
- smprintf(s, "Adding file part %i %i\n",*Pos,j);
+ smprintf(s, "Adding file part %ld %i\n", (long)*Pos,j);
error=GSM_WaitFor (s, Add, 14+j, 0x6D, 4, ID_AddFile);
if (error != ERR_NONE) return error;
*Pos = *Pos + j;
@@ -1186,7 +1186,7 @@ static GSM_Error N6510_GetNextFileFolder2(GSM_StateMachine *s, GSM_File *File, g
return error;
}
-static GSM_Error N6510_GetFilePart2(GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size)
+static GSM_Error N6510_GetFilePart2(GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size)
{
int old,j;
GSM_Error error;
@@ -1318,7 +1318,7 @@ static GSM_Error N6510_SetFileAttributes2(GSM_StateMachine *s, GSM_File *File)
return ERR_NONE;
}
-static GSM_Error N6510_AddFilePart2(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+static GSM_Error N6510_AddFilePart2(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_Error error;
int j,P;
@@ -1365,7 +1365,7 @@ static GSM_Error N6510_AddFilePart2(GSM_StateMachine *s, GSM_File *File, int *Po
req[13] = j % 256;
memcpy(req+14,File->Buffer+(*Pos),j);
- smprintf(s, "Adding file part %i %i\n",*Pos,j);
+ smprintf(s, "Adding file part %ld %i\n",(long)*Pos,j);
error=GSM_WaitFor (s, req, 14+j, 0x6D, 4, ID_AddFile);
if (error != ERR_NONE) return error;
*Pos = *Pos + j;
@@ -1681,7 +1681,7 @@ GSM_Error N6510_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, gboolean
return N6510_GetNextFileFolder2(s,File,start);
}
-GSM_Error N6510_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size)
+GSM_Error N6510_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size)
{
GSM_File File2;
char buf[20 + (2 * (GSM_MAX_FILENAME_ID_LENGTH + 1))];
@@ -1711,7 +1711,7 @@ GSM_Error N6510_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, in
}
}
-GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error N6510_AddFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_File File2;
GSM_Error error;
@@ -2126,7 +2126,8 @@ GSM_Error N6510_GetNextMMSFileInfo(GSM_StateMachine *s, unsigned char *FileID, i
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
GSM_Error error;
GSM_File file;
- int Handle,Size;
+ int Handle;
+ size_t Size;
if (start) {
error = N6510_GetMMSFolders(s, &folders);
@@ -2497,7 +2498,7 @@ GSM_Error N6510_DecodeFilesystemSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *sm
break;
}
if (unknown) {
- smprintf(s, "WARNING: Unknown block 0x%02x, see <http://wammu.eu/support/bugs/> how to report\n", FFF->Buffer[pos]);
+ smprintf(s, "WARNING: Unknown block 0x%02x, see <https://wammu.eu/support/bugs/> how to report\n", FFF->Buffer[pos]);
DumpMessage(&(s->di), FFF->Buffer + pos, 3 + (FFF->Buffer[pos + 1] << 8) + FFF->Buffer[pos + 2]);
#ifdef DEBUG
} else {
@@ -2529,7 +2530,8 @@ GSM_Error N6510_GetNextFilesystemSMS(GSM_StateMachine *s, GSM_MultiSMSMessage *s
{
GSM_Phone_N6510Data *Priv = &s->Phone.Data.Priv.N6510;
unsigned char folderid;
- int location,Size,Handle;
+ int location,Handle;
+ size_t Size;
GSM_Error error;
GSM_File FFF;
gboolean start2=start;
diff --git a/libgammu/phone/nokia/dct4s40/6510/6510file.h b/libgammu/phone/nokia/dct4s40/6510/6510file.h
index ed7e94d..12810e9 100644
--- a/libgammu/phone/nokia/dct4s40/6510/6510file.h
+++ b/libgammu/phone/nokia/dct4s40/6510/6510file.h
@@ -4,8 +4,8 @@ GSM_Error N6510_GetNextFileFolder (GSM_StateMachine *s, GSM_File *File, gboolea
GSM_Error N6510_GetFolderListing (GSM_StateMachine *s, GSM_File *File, gboolean start);
GSM_Error N6510_AddFolder (GSM_StateMachine *s, GSM_File *File);
GSM_Error N6510_DeleteFolder (GSM_StateMachine *s, unsigned char *ID);
-GSM_Error N6510_GetFilePart (GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size);
-GSM_Error N6510_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle);
+GSM_Error N6510_GetFilePart (GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size);
+GSM_Error N6510_AddFilePart (GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle);
GSM_Error N6510_DeleteFile (GSM_StateMachine *s, unsigned char *ID);
GSM_Error N6510_SetFileAttributes (GSM_StateMachine *s, GSM_File *File);
GSM_Error N6510_GetNextRootFolder (GSM_StateMachine *s, GSM_File *File);
diff --git a/libgammu/phone/nokia/dct4s40/6510/n6510.c b/libgammu/phone/nokia/dct4s40/6510/n6510.c
index 9796c74..cde4ff7 100644
--- a/libgammu/phone/nokia/dct4s40/6510/n6510.c
+++ b/libgammu/phone/nokia/dct4s40/6510/n6510.c
@@ -2229,8 +2229,14 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
if (((length + pad) % 2)) pad = 2; else pad = 0;
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc1].HomePage, TRUE);
- if (settings->Settings[loc1].IsContinuous) req[pos] = 0x01; pos++;
- if (settings->Settings[loc1].IsSecurity) req[pos] = 0x01; pos++;
+ if (settings->Settings[loc1].IsContinuous) {
+ req[pos] = 0x01;
+ }
+ pos++;
+ if (settings->Settings[loc1].IsSecurity) {
+ req[pos] = 0x01;
+ }
+ pos++;
} else if (loc2 != -1) {
/* Name */
length = UnicodeLength(settings->Settings[loc2].Title);
@@ -2242,8 +2248,14 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
if (((length + pad) % 2)) pad = 2; else pad = 0;
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc2].HomePage, TRUE);
- if (settings->Settings[loc2].IsContinuous) req[pos] = 0x01; pos++;
- if (settings->Settings[loc2].IsSecurity) req[pos] = 0x01; pos++;
+ if (settings->Settings[loc2].IsContinuous) {
+ req[pos] = 0x01;
+ }
+ pos++;
+ if (settings->Settings[loc2].IsSecurity) {
+ req[pos] = 0x01;
+ }
+ pos++;
} else {
/* Name */
length = 0;
@@ -2295,8 +2307,14 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
req[pos++] = length % 256;
if (loc1 != -1) {
- if (!settings->Settings[loc1].IsNormalAuthentication) req[pos]=0x01; pos++;
- if (settings->Settings[loc1].IsISDNCall) req[pos]=0x01; pos++;
+ if (!settings->Settings[loc1].IsNormalAuthentication) {
+ req[pos]=0x01;
+ }
+ pos++;
+ if (settings->Settings[loc1].IsISDNCall) {
+ req[pos]=0x01;
+ }
+ pos++;
switch (settings->Settings[loc1].Speed) {
case WAPSETTINGS_SPEED_AUTO : break;
case WAPSETTINGS_SPEED_9600 : req[pos]=0x01; break;
@@ -2304,7 +2322,9 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
}
pos++;
req[pos++]=0x01;
- if (!settings->Settings[loc1].ManualLogin) req[pos] = 0x01; pos++;
+ if (!settings->Settings[loc1].ManualLogin) {
+ req[pos] = 0x01;
+ }pos++;
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc1].IPAddress, FALSE);
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc1].DialUp, TRUE);
@@ -2337,9 +2357,18 @@ static GSM_Error N6510_SetConnectionSettings(GSM_StateMachine *s, GSM_MultiWAPSe
req[pos++] = length % 256;
if (loc2 != -1) {
- if (!settings->Settings[loc2].IsNormalAuthentication) req[pos] = 0x01; pos++;
- if (!settings->Settings[loc2].IsContinuous) req[pos] = 0x01; pos++;
- if (!settings->Settings[loc2].ManualLogin) req[pos] = 0x01; pos++;
+ if (!settings->Settings[loc2].IsNormalAuthentication) {
+ req[pos] = 0x01;
+ }
+ pos++;
+ if (!settings->Settings[loc2].IsContinuous) {
+ req[pos] = 0x01;
+ }
+ pos++;
+ if (!settings->Settings[loc2].ManualLogin) {
+ req[pos] = 0x01;
+ }
+ pos++;
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc2].DialUp, FALSE);
pos += NOKIA_SetUnicodeString(s, req + pos, settings->Settings[loc2].IPAddress, TRUE);
diff --git a/libgammu/phone/nokia/wd2/n3650.c b/libgammu/phone/nokia/wd2/n3650.c
index 6fc9ee5..8a68da3 100644
--- a/libgammu/phone/nokia/wd2/n3650.c
+++ b/libgammu/phone/nokia/wd2/n3650.c
@@ -43,7 +43,7 @@ static GSM_Error N3650_ReplyGetFilePart(GSM_Protocol_Message *msg, GSM_StateMach
return ERR_NONE;
}
-static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle UNUSED, int *Size)
+static GSM_Error N3650_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle UNUSED, size_t *Size)
{
unsigned int len=10,i;
GSM_Error error;
diff --git a/libgammu/phone/obex/mobex.c b/libgammu/phone/obex/mobex.c
index 81dcd4f..fe3b1ed 100644
--- a/libgammu/phone/obex/mobex.c
+++ b/libgammu/phone/obex/mobex.c
@@ -282,6 +282,9 @@ GSM_Error MOBEX_GetNextEntry(GSM_StateMachine *s, const char *path, const gboole
if (*pos + 4 > *size) {
return ERR_EMPTY;
}
+ if (*data == NULL) {
+ return ERR_BUG;
+ }
/* Return values */
*entry = *data + *pos + 4;
diff --git a/libgammu/phone/obex/obexfunc.h b/libgammu/phone/obex/obexfunc.h
index ac7703c..f7fbf67 100644
--- a/libgammu/phone/obex/obexfunc.h
+++ b/libgammu/phone/obex/obexfunc.h
@@ -10,9 +10,9 @@
extern GSM_Reply_Function OBEXGENReplyFunctions[];
extern GSM_Error OBEXGEN_InitialiseVars(GSM_StateMachine *s);
extern void OBEXGEN_FreeVars(GSM_StateMachine *s);
-extern GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size);
-extern GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle);
-extern GSM_Error OBEXGEN_SendFilePart (GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle);
+extern GSM_Error OBEXGEN_GetFilePart (GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size);
+extern GSM_Error OBEXGEN_AddFilePart (GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle);
+extern GSM_Error OBEXGEN_SendFilePart (GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle);
extern GSM_Error OBEXGEN_GetNextFileFolder(GSM_StateMachine *s, GSM_File *File, gboolean start);
extern GSM_Error OBEXGEN_Disconnect (GSM_StateMachine *s);
extern GSM_Error OBEXGEN_Connect (GSM_StateMachine *s, OBEX_Service service);
diff --git a/libgammu/phone/obex/obexgen.c b/libgammu/phone/obex/obexgen.c
index af3808c..4802023 100644
--- a/libgammu/phone/obex/obexgen.c
+++ b/libgammu/phone/obex/obexgen.c
@@ -747,7 +747,7 @@ static GSM_Error OBEXGEN_ReplyAddFilePart(GSM_Protocol_Message *msg, GSM_StateMa
return ERR_UNKNOWNRESPONSE;
}
-GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle UNUSED, gboolean HardDelete)
+GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle UNUSED, gboolean HardDelete)
{
GSM_Error error;
size_t j;
@@ -815,22 +815,22 @@ GSM_Error OBEXGEN_PrivAddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos,
j = File->Used - *Pos;
/* End of file body block */
OBEXAddBlock(req, &Current, 0x49, File->Buffer+(*Pos), j);
- smprintf(s, "Adding last file part %i %ld\n", *Pos, (long)j);
+ smprintf(s, "Adding last file part %ld %ld\n", (long)*Pos, (long)j);
*Pos = *Pos + j;
- error = GSM_WaitFor (s, req, Current, 0x82, OBEX_TIMEOUT * 10, ID_AddFile);
+ error = GSM_WaitFor (s, req, (long)Current, 0x82, OBEX_TIMEOUT * 10, ID_AddFile);
if (error != ERR_NONE) return error;
return ERR_EMPTY;
} else {
/* File body block */
OBEXAddBlock(req, &Current, 0x48, File->Buffer+(*Pos), j);
- smprintf(s, "Adding file part %i %ld\n", *Pos, (long)j);
+ smprintf(s, "Adding file part %ld %ld\n", (long)*Pos, (long)j);
*Pos = *Pos + j;
- error=GSM_WaitFor (s, req, Current, 0x02, OBEX_TIMEOUT * 10, ID_AddFile);
+ error=GSM_WaitFor (s, req, (long)Current, 0x02, OBEX_TIMEOUT * 10, ID_AddFile);
}
return error;
}
-GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_Error error;
@@ -850,7 +850,7 @@ GSM_Error OBEXGEN_AddFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int
return error;
}
-GSM_Error OBEXGEN_SendFilePart(GSM_StateMachine *s, GSM_File *File, int *Pos, int *Handle)
+GSM_Error OBEXGEN_SendFilePart(GSM_StateMachine *s, GSM_File *File, size_t *Pos, int *Handle)
{
GSM_Error error;
@@ -1067,7 +1067,7 @@ static GSM_Error OBEXGEN_PrivGetFilePart(GSM_StateMachine *s, GSM_File *File, gb
return ERR_EMPTY;
}
-GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, int *Size)
+GSM_Error OBEXGEN_GetFilePart(GSM_StateMachine *s, GSM_File *File, int *Handle, size_t *Size)
{
GSM_Error error;
@@ -1395,7 +1395,8 @@ GSM_Error OBEXGEN_SetFile(GSM_StateMachine *s, const char *FileName, const unsig
{
GSM_Error error = ERR_NONE;
GSM_File File;
- int Pos = 0, Handle;
+ size_t Pos = 0;
+ int Handle;
/* Fill file structure */
EncodeUnicode(File.ID_FullName, FileName, strlen(FileName));
diff --git a/libgammu/phone/pfunc.c b/libgammu/phone/pfunc.c
index 92afbb0..22bcd9c 100644
--- a/libgammu/phone/pfunc.c
+++ b/libgammu/phone/pfunc.c
@@ -172,7 +172,8 @@ GSM_Error PHONE_FindDataFile(GSM_StateMachine *s, GSM_File * File, const char *E
GSM_Error PHONE_UploadFile(GSM_StateMachine *s, GSM_File * File)
{
- int Pos = 0, Handle = 0;
+ size_t Pos = 0;
+ int Handle = 0;
GSM_Error error = ERR_NONE;;
while (error == ERR_NONE) {