Break some long lines to (hopefully) make the code more readable.
Signed-off-by: Linus Walleij <[email protected]>
diff --git a/src/libmtp.c b/src/libmtp.c
index 7f86c8d..4138fce 100644
--- a/src/libmtp.c
+++ b/src/libmtp.c
@@ -2530,13 +2530,15 @@
/* Copy all of the other MTP oprierties into the per-object proplist */
if (params->objects[i].nrofmtpprops) {
- newprops = realloc(params->objects[i].mtpprops,(params->objects[i].nrofmtpprops+1)*sizeof(MTPProperties));
+ newprops = realloc(params->objects[i].mtpprops,
+ (params->objects[i].nrofmtpprops+1)*sizeof(MTPProperties));
} else {
newprops = calloc(sizeof(MTPProperties),1);
}
if (!newprops) return 0; /* FIXME: error handling? */
params->objects[i].mtpprops = newprops;
- memcpy(¶ms->objects[i].mtpprops[params->objects[i].nrofmtpprops],&props[j],sizeof(props[j]));
+ memcpy(¶ms->objects[i].mtpprops[params->objects[i].nrofmtpprops],
+ &props[j],sizeof(props[j]));
params->objects[i].nrofmtpprops++;
params->objects[i].flags |= PTPOBJECT_MTPPROPLIST_LOADED;
break;
@@ -2583,10 +2585,12 @@
// Now descend into any subdirectories found
for (i = 0; i < currentHandles.n; i++) {
PTPObject *ob;
- ret = ptp_object_want(params,currentHandles.Handler[i],PTPOBJECT_OBJECTINFO_LOADED, &ob);
+ ret = ptp_object_want(params,currentHandles.Handler[i],
+ PTPOBJECT_OBJECTINFO_LOADED, &ob);
if (ret == PTP_RC_OK) {
if (ob->oi.ObjectFormat == PTP_OFC_Association)
- get_handles_recursively(device, params, storageid, currentHandles.Handler[i]);
+ get_handles_recursively(device, params,
+ storageid, currentHandles.Handler[i]);
} else {
add_error_to_errorstack(device,
LIBMTP_ERROR_CONNECTING,
@@ -2658,7 +2662,8 @@
PTPObject *ob, *xob;
ob = ¶ms->objects[i];
- ret = ptp_object_want(params,params->objects[i].oid,PTPOBJECT_OBJECTINFO_LOADED, &xob);
+ ret = ptp_object_want(params,params->objects[i].oid,
+ PTPOBJECT_OBJECTINFO_LOADED, &xob);
if (ret != PTP_RC_OK) {
LIBMTP_ERROR("broken! %x not found\n", params->objects[i].oid);
}
@@ -2672,7 +2677,8 @@
continue;
/* Only look in the root folder */
if (ob->oi.ParentObject == 0xffffffffU) {
- LIBMTP_ERROR("object %x has parent 0xffffffff (-1) continuing anyway\n", ob->oid);
+ LIBMTP_ERROR("object %x has parent 0xffffffff (-1) continuing anyway\n",
+ ob->oid);
} else if (ob->oi.ParentObject != 0x00000000U)
continue;
/* Only look in the primary storage */
@@ -2840,7 +2846,8 @@
} else {
while(storage != NULL) {
// These storages cannot be used.
- if (storage->StorageType == PTP_ST_FixedROM || storage->StorageType == PTP_ST_RemovableROM) {
+ if (storage->StorageType == PTP_ST_FixedROM ||
+ storage->StorageType == PTP_ST_RemovableROM) {
storage = storage->next;
continue;
}
@@ -2851,7 +2858,8 @@
continue;
}
// Also check the access capability to avoid e.g. deletable only storages
- if (storage->AccessCapability == PTP_AC_ReadOnly || storage->AccessCapability == PTP_AC_ReadOnly_with_Object_Deletion) {
+ if (storage->AccessCapability == PTP_AC_ReadOnly ||
+ storage->AccessCapability == PTP_AC_ReadOnly_with_Object_Deletion) {
storage = storage->next;
continue;
}
@@ -2865,7 +2873,8 @@
}
}
if (storage == NULL) {
- add_error_to_errorstack(device, LIBMTP_ERROR_STORAGE_FULL, "get_writeable_storageid(): "
+ add_error_to_errorstack(device, LIBMTP_ERROR_STORAGE_FULL,
+ "get_writeable_storageid(): "
"all device storage is full or corrupt.");
return -1;
}
@@ -2899,7 +2908,8 @@
ret = ptp_getstorageinfo(params, storage->id, &storageInfo);
if (ret != PTP_RC_OK) {
- add_ptp_error_to_errorstack(device, ret, "get_storage_freespace(): could not get storage info.");
+ add_ptp_error_to_errorstack(device, ret,
+ "get_storage_freespace(): could not get storage info.");
return -1;
}
if (storage->StorageDescription != NULL) {
@@ -2945,9 +2955,12 @@
printf(" Model: %s\n", params->deviceinfo.Model);
printf(" Device version: %s\n", params->deviceinfo.DeviceVersion);
printf(" Serial number: %s\n", params->deviceinfo.SerialNumber);
- printf(" Vendor extension ID: 0x%08x\n", params->deviceinfo.VendorExtensionID);
- printf(" Vendor extension description: %s\n", params->deviceinfo.VendorExtensionDesc);
- printf(" Detected object size: %d bits\n", device->object_bitsize);
+ printf(" Vendor extension ID: 0x%08x\n",
+ params->deviceinfo.VendorExtensionID);
+ printf(" Vendor extension description: %s\n",
+ params->deviceinfo.VendorExtensionDesc);
+ printf(" Detected object size: %d bits\n",
+ device->object_bitsize);
printf(" Extensions:\n");
while (tmpext != NULL) {
printf(" %s: %d.%d\n",
@@ -2960,7 +2973,8 @@
for (i=0;i<params->deviceinfo.OperationsSupported_len;i++) {
char txt[256];
- (void) ptp_render_opcode (params, params->deviceinfo.OperationsSupported[i], sizeof(txt), txt);
+ (void) ptp_render_opcode(params, params->deviceinfo.OperationsSupported[i],
+ sizeof(txt), txt);
printf(" %04x: %s\n", params->deviceinfo.OperationsSupported[i], txt);
}
printf("Events supported:\n");
@@ -2973,10 +2987,12 @@
}
printf("Device Properties Supported:\n");
for (i=0;i<params->deviceinfo.DevicePropertiesSupported_len;i++) {
- char const *propdesc = ptp_get_property_description(params, params->deviceinfo.DevicePropertiesSupported[i]);
+ char const *propdesc = ptp_get_property_description(params,
+ params->deviceinfo.DevicePropertiesSupported[i]);
if (propdesc != NULL) {
- printf(" 0x%04x: %s\n", params->deviceinfo.DevicePropertiesSupported[i], propdesc);
+ printf(" 0x%04x: %s\n",
+ params->deviceinfo.DevicePropertiesSupported[i], propdesc);
} else {
uint16_t prop = params->deviceinfo.DevicePropertiesSupported[i];
printf(" 0x%04x: Unknown property\n", prop);
@@ -2992,22 +3008,29 @@
uint32_t propcnt = 0;
int j;
- (void) ptp_render_ofc (params, params->deviceinfo.ImageFormats[i], sizeof(txt), txt);
+ (void) ptp_render_ofc (params, params->deviceinfo.ImageFormats[i],
+ sizeof(txt), txt);
printf(" %04x: %s\n", params->deviceinfo.ImageFormats[i], txt);
- ret = ptp_mtp_getobjectpropssupported (params, params->deviceinfo.ImageFormats[i], &propcnt, &props);
+ ret = ptp_mtp_getobjectpropssupported (params,
+ params->deviceinfo.ImageFormats[i], &propcnt, &props);
if (ret != PTP_RC_OK) {
- add_ptp_error_to_errorstack(device, ret, "LIBMTP_Dump_Device_Info(): error on query for object properties.");
+ add_ptp_error_to_errorstack(device, ret, "LIBMTP_Dump_Device_Info(): "
+ "error on query for object properties.");
} else {
for (j=0;j<propcnt;j++) {
PTPObjectPropDesc opd;
int k;
- printf(" %04x: %s", props[j], LIBMTP_Get_Property_Description(map_ptp_property_to_libmtp_property(props[j])));
+ printf(" %04x: %s", props[j],
+ LIBMTP_Get_Property_Description(map_ptp_property_to_libmtp_property(props[j])));
// Get a more verbose description
- ret = ptp_mtp_getobjectpropdesc(params, props[j], params->deviceinfo.ImageFormats[i], &opd);
+ ret = ptp_mtp_getobjectpropdesc(params, props[j],
+ params->deviceinfo.ImageFormats[i],
+ &opd);
if (ret != PTP_RC_OK) {
- add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL, "LIBMTP_Dump_Device_Info(): "
+ add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
+ "LIBMTP_Dump_Device_Info(): "
"could not get property description.");
break;
}
@@ -3222,7 +3245,8 @@
}
}
- if(storage != NULL && ptp_operation_issupported(params,PTP_OC_GetStorageInfo)) {
+ if(storage != NULL &&
+ ptp_operation_issupported(params,PTP_OC_GetStorageInfo)) {
printf("Storage Devices:\n");
while(storage != NULL) {
printf(" StorageID: 0x%08x\n",storage->id);
@@ -3280,9 +3304,12 @@
printf("UNKNOWN access capability\n");
break;
}
- printf(" MaxCapacity: %llu\n", (long long unsigned int) storage->MaxCapacity);
- printf(" FreeSpaceInBytes: %llu\n", (long long unsigned int) storage->FreeSpaceInBytes);
- printf(" FreeSpaceInObjects: %llu\n", (long long unsigned int) storage->FreeSpaceInObjects);
+ printf(" MaxCapacity: %llu\n",
+ (long long unsigned int) storage->MaxCapacity);
+ printf(" FreeSpaceInBytes: %llu\n",
+ (long long unsigned int) storage->FreeSpaceInBytes);
+ printf(" FreeSpaceInObjects: %llu\n",
+ (long long unsigned int) storage->FreeSpaceInObjects);
printf(" StorageDescription: %s\n",storage->StorageDescription);
printf(" VolumeIdentifier: %s\n",storage->VolumeIdentifier);
storage = storage->next;
@@ -3290,14 +3317,22 @@
}
printf("Special directories:\n");
- printf(" Default music folder: 0x%08x\n", device->default_music_folder);
- printf(" Default playlist folder: 0x%08x\n", device->default_playlist_folder);
- printf(" Default picture folder: 0x%08x\n", device->default_picture_folder);
- printf(" Default video folder: 0x%08x\n", device->default_video_folder);
- printf(" Default organizer folder: 0x%08x\n", device->default_organizer_folder);
- printf(" Default zencast folder: 0x%08x\n", device->default_zencast_folder);
- printf(" Default album folder: 0x%08x\n", device->default_album_folder);
- printf(" Default text folder: 0x%08x\n", device->default_text_folder);
+ printf(" Default music folder: 0x%08x\n",
+ device->default_music_folder);
+ printf(" Default playlist folder: 0x%08x\n",
+ device->default_playlist_folder);
+ printf(" Default picture folder: 0x%08x\n",
+ device->default_picture_folder);
+ printf(" Default video folder: 0x%08x\n",
+ device->default_video_folder);
+ printf(" Default organizer folder: 0x%08x\n",
+ device->default_organizer_folder);
+ printf(" Default zencast folder: 0x%08x\n",
+ device->default_zencast_folder);
+ printf(" Default album folder: 0x%08x\n",
+ device->default_album_folder);
+ printf(" Default text folder: 0x%08x\n",
+ device->default_text_folder);
}
/**
@@ -3313,7 +3348,8 @@
if (!ptp_operation_issupported(params,PTP_OC_ResetDevice)) {
add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
- "LIBMTP_Reset_Device(): device does not support resetting.");
+ "LIBMTP_Reset_Device(): "
+ "device does not support resetting.");
return -1;
}
ret = ptp_resetdevice(params);
@@ -3596,9 +3632,12 @@
return -1;
}
- ret = ptp_getdevicepropvalue(params, PTP_DPC_BatteryLevel, &propval, PTP_DTC_UINT8);
+ ret = ptp_getdevicepropvalue(params, PTP_DPC_BatteryLevel,
+ &propval, PTP_DTC_UINT8);
if (ret != PTP_RC_OK) {
- add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_Batterylevel(): could not get device property value.");
+ add_ptp_error_to_errorstack(device, ret,
+ "LIBMTP_Get_Batterylevel(): "
+ "could not get device property value.");
return -1;
}
@@ -3618,19 +3657,22 @@
* @param storage the actual storage to format.
* @return 0 on success, any other value means failure.
*/
-int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *device, LIBMTP_devicestorage_t *storage)
+int LIBMTP_Format_Storage(LIBMTP_mtpdevice_t *device,
+ LIBMTP_devicestorage_t *storage)
{
uint16_t ret;
PTPParams *params = (PTPParams *) device->params;
if (!ptp_operation_issupported(params,PTP_OC_FormatStore)) {
add_error_to_errorstack(device, LIBMTP_ERROR_GENERAL,
- "LIBMTP_Format_Storage(): device does not support formatting storage.");
+ "LIBMTP_Format_Storage(): "
+ "device does not support formatting storage.");
return -1;
}
ret = ptp_formatstore(params, storage->id);
if (ret != PTP_RC_OK) {
- add_ptp_error_to_errorstack(device, ret, "LIBMTP_Format_Storage(): failed to format storage.");
+ add_ptp_error_to_errorstack(device, ret, "LIBMTP_Format_Storage(): "
+ "failed to format storage.");
return -1;
}
return 0;
@@ -3667,7 +3709,9 @@
if (ret != PTP_RC_OK) {
// TODO: add a note on WHICH property that we failed to get.
*unicstring = NULL;
- add_ptp_error_to_errorstack(device, ret, "get_device_unicode_property(): failed to get unicode property.");
+ add_ptp_error_to_errorstack(device, ret,
+ "get_device_unicode_property(): "
+ "failed to get unicode property.");
return -1;
}
@@ -3713,7 +3757,8 @@
*/
int LIBMTP_Get_Device_Certificate(LIBMTP_mtpdevice_t *device, char ** const devcert)
{
- return get_device_unicode_property(device, devcert, PTP_DPC_MTP_DeviceCertificate);
+ return get_device_unicode_property(device, devcert,
+ PTP_DPC_MTP_DeviceCertificate);
}
/**
@@ -3753,13 +3798,15 @@
}
// The forgotten Ogg support on YP-10 and others...
if (FLAG_OGG_IS_UNKNOWN(ptp_usb)) {
- localtypes = (uint16_t *) realloc(localtypes, (params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
+ localtypes = (uint16_t *) realloc(localtypes,
+ (params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
localtypes[localtypelen] = LIBMTP_FILETYPE_OGG;
localtypelen++;
}
// The forgotten FLAC support on Cowon iAudio S9 and others...
if (FLAG_FLAC_IS_UNKNOWN(ptp_usb)) {
- localtypes = (uint16_t *) realloc(localtypes, (params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
+ localtypes = (uint16_t *) realloc(localtypes,
+ (params->deviceinfo.ImageFormats_len+1) * sizeof(uint16_t));
localtypes[localtypelen] = LIBMTP_FILETYPE_FLAC;
localtypelen++;
}
@@ -3817,7 +3864,8 @@
if (!ptp_operation_issupported(params,PTP_OC_GetStorageInfo)) {
for (i = 0; i < storageIDs.n; i++) {
- storage = (LIBMTP_devicestorage_t *) malloc(sizeof(LIBMTP_devicestorage_t));
+ storage = (LIBMTP_devicestorage_t *)
+ malloc(sizeof(LIBMTP_devicestorage_t));
storage->prev = storageprev;
if (storageprev != NULL)
storageprev->next = storage;
@@ -3844,14 +3892,16 @@
uint16_t ret;
ret = ptp_getstorageinfo(params, storageIDs.Storage[i], &storageInfo);
if (ret != PTP_RC_OK) {
- add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_Storage(): Could not get storage info.");
+ add_ptp_error_to_errorstack(device, ret, "LIBMTP_Get_Storage(): "
+ "Could not get storage info.");
if (device->storage != NULL) {
free_storage_list(device);
}
return -1;
}
- storage = (LIBMTP_devicestorage_t *) malloc(sizeof(LIBMTP_devicestorage_t));
+ storage = (LIBMTP_devicestorage_t *)
+ malloc(sizeof(LIBMTP_devicestorage_t));
storage->prev = storageprev;
if (storageprev != NULL)
storageprev->next = storage;