Skip to content
Snippets Groups Projects
Commit bc16423b authored by Ronny Nilsson's avatar Ronny Nilsson
Browse files

Use a constant define for volume id where appropriate.

parent 9a5233cd
No related branches found
No related tags found
No related merge requests found
...@@ -143,7 +143,7 @@ static char* ubi_path_by_id(int devId, int volId) ...@@ -143,7 +143,7 @@ static char* ubi_path_by_id(int devId, int volId)
} }
dstPath[DST_LEN - 1] = 0; dstPath[DST_LEN - 1] = 0;
if(volId == -1) return dstPath; if(volId == METAINVALID) return dstPath;
/* If the volume is supposed to exsit; verify it does. /* If the volume is supposed to exsit; verify it does.
* Otherwise; verify it does NOT exist. */ * Otherwise; verify it does NOT exist. */
...@@ -218,7 +218,7 @@ int ubi_erase_volume(int volId) ...@@ -218,7 +218,7 @@ int ubi_erase_volume(int volId)
return -1; return -1;
} }
nodePath = ubi_path_by_id(devInfo.dev_num, -1); nodePath = ubi_path_by_id(devInfo.dev_num, METAINVALID);
if(ubi_rmvol(libubi, nodePath, volId) && errno != ENOENT) { if(ubi_rmvol(libubi, nodePath, volId) && errno != ENOENT) {
fprintf(stderr, "Error deleting volume %d: %s\n", volId, strerror(errno)); fprintf(stderr, "Error deleting volume %d: %s\n", volId, strerror(errno));
free(nodePath); free(nodePath);
...@@ -251,7 +251,7 @@ int ubi_create_volume(int volId, long long size) ...@@ -251,7 +251,7 @@ int ubi_create_volume(int volId, long long size)
mkReq.bytes = size; mkReq.bytes = size;
mkReq.vol_type = UBI_STATIC_VOLUME; mkReq.vol_type = UBI_STATIC_VOLUME;
mkReq.name = name; mkReq.name = name;
nodePath = ubi_path_by_id(devInfo.dev_num, -1); nodePath = ubi_path_by_id(devInfo.dev_num, METAINVALID);
errno = 0; errno = 0;
if(ubi_mkvol(libubi, nodePath, &mkReq)) { if(ubi_mkvol(libubi, nodePath, &mkReq)) {
...@@ -423,7 +423,7 @@ static int ubi_rename_volume(int volId, const char *name) ...@@ -423,7 +423,7 @@ static int ubi_rename_volume(int volId, const char *name)
rnvol.ents[0].name_len = strlen(name); rnvol.ents[0].name_len = strlen(name);
strncpy(rnvol.ents[0].name, name, UBI_MAX_VOLUME_NAME + 1); strncpy(rnvol.ents[0].name, name, UBI_MAX_VOLUME_NAME + 1);
nodePath = ubi_path_by_id(devInfo.dev_num, -1); nodePath = ubi_path_by_id(devInfo.dev_num, METAINVALID);
if(!nodePath || ubi_rnvols(libubi, nodePath, &rnvol)) { if(!nodePath || ubi_rnvols(libubi, nodePath, &rnvol)) {
fprintf(stderr, "Error renaming %d to %s: %s\n", volId, fprintf(stderr, "Error renaming %d to %s: %s\n", volId,
...@@ -593,7 +593,7 @@ static int meta_find_all(void) ...@@ -593,7 +593,7 @@ static int meta_find_all(void)
case METAVOLID3: case METAVOLID3:
metaInfos[medaIdx].found = 1; metaInfos[medaIdx].found = 1;
metaInfos[medaIdx].volInfo = volInfo; metaInfos[medaIdx].volInfo = volInfo;
metaInfos[medaIdx].nodePath = ubi_path_by_id(devInfo.dev_num, -1); metaInfos[medaIdx].nodePath = ubi_path_by_id(devInfo.dev_num, METAINVALID);
metaInfos[medaIdx].volPath = ubi_path_by_id(devInfo.dev_num, volInfo.vol_id); metaInfos[medaIdx].volPath = ubi_path_by_id(devInfo.dev_num, volInfo.vol_id);
if(meta_find_seqno(metaInfos + medaIdx)) { if(meta_find_seqno(metaInfos + medaIdx)) {
if (verbose) { if (verbose) {
...@@ -806,7 +806,7 @@ static int meta_manage_vols(int readonly) ...@@ -806,7 +806,7 @@ static int meta_manage_vols(int readonly)
} }
else { else {
newMeta = METAVOLID2; newMeta = METAVOLID2;
delMeta = -1; delMeta = METAINVALID;
} }
newBank = 1; newBank = 1;
break; break;
...@@ -822,7 +822,7 @@ static int meta_manage_vols(int readonly) ...@@ -822,7 +822,7 @@ static int meta_manage_vols(int readonly)
} }
else { else {
newMeta = METAVOLID0; newMeta = METAVOLID0;
delMeta = -1; delMeta = METAINVALID;
} }
newBank = 0; newBank = 0;
break; break;
...@@ -831,7 +831,7 @@ static int meta_manage_vols(int readonly) ...@@ -831,7 +831,7 @@ static int meta_manage_vols(int readonly)
if (verbose) { if (verbose) {
printf("Highest sequence number found is %d.\n", highSeqNo); printf("Highest sequence number found is %d.\n", highSeqNo);
printf("Will create volume %d", newMeta); printf("Will create volume %d", newMeta);
if(delMeta >= 0) printf(" to replace volume %d", delMeta); if(delMeta != METAINVALID) printf(" to replace volume %d", delMeta);
printf(" in flash bank %d.\n", newBank); printf(" in flash bank %d.\n", newBank);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment