[libdvdnav-devel] [Git][videolan/libdvdread][master] 6 commits: dvd_udf: document the return values of UDFGetAVDP
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Fri Aug 7 15:31:57 UTC 2026
Jean-Baptiste Kempf pushed to branch master at VideoLAN / libdvdread
Commits:
c012dd88 by Steve Lhomme at 2026-08-07T17:30:25+02:00
dvd_udf: document the return values of UDFGetAVDP
- - - - -
602cb1d3 by Steve Lhomme at 2026-08-07T17:30:25+02:00
dvd_udf: only return 0 or 1 in UDFGetAVDP()
The callers only check against a return value of 0 for success/error.
- - - - -
99dc1062 by Steve Lhomme at 2026-08-07T17:30:25+02:00
dvd_udf: fix bogus return values on error
The functions are supposed to return 0 on error. That's the only value
that the callers check and how they are documented.
Added in b1f3681b2b7e19c0c060771f9d5acc2db2ec7a1a.
- - - - -
172ca84c by Steve Lhomme at 2026-08-07T17:30:25+02:00
dvd_udf: return 0 on error or a start block number in UDFFindFile()
Turning a negative return value from DVDReadLBUDF() (error) into a uint32_t
will pretend there was no error.
- - - - -
92f3a6e5 by Steve Lhomme at 2026-08-07T17:30:25+02:00
dvd_udf: return a ssize_t from internal function
Either it's a negative error code or a size_t that should not be very large.
- - - - -
918878e0 by Saifelden Mohamed Ismail at 2026-08-07T17:30:25+02:00
dvd_udf: don't hide read errors in UDFGetAVDP
- - - - -
1 changed file:
- src/dvd_udf.c
Changes:
=====================================
src/dvd_udf.c
=====================================
@@ -44,7 +44,7 @@
#include "dvdread/dvd_udf.h"
/* It's required to either fail or deliver all the blocks asked for. */
-static int DVDReadLBUDF( dvd_reader_t *ctx, uint32_t lb_number,
+static ssize_t DVDReadLBUDF( dvd_reader_t *ctx, uint32_t lb_number,
size_t block_count, unsigned char *data,
int encrypted )
{
@@ -65,7 +65,7 @@ static int DVDReadLBUDF( dvd_reader_t *ctx, uint32_t lb_number,
lb_number += (uint32_t)ret;
}
- return block_count;
+ return (ssize_t)block_count;
}
struct Partition {
@@ -512,7 +512,7 @@ static int UDFMapICB( dvd_reader_t *ctx, struct AD ICB, uint8_t *FileType,
uint32_t lbnum;
uint16_t TagID;
struct icbmap tmpmap;
- int ret;
+ ssize_t ret;
lbnum = partition->Start + ICB.Location;
tmpmap.lbn = lbnum;
@@ -525,9 +525,9 @@ static int UDFMapICB( dvd_reader_t *ctx, struct AD ICB, uint8_t *FileType,
do {
ret = DVDReadLBUDF( ctx, lbnum++, 1, LogBlock, 0 );
if( ret < 0 ) {
- return ret;
+ return 0;
}
- else if( ret == 0 ) {
+ if( ret == 0 ) {
TagID = 0;
}
else {
@@ -567,7 +567,7 @@ static int UDFScanDir( dvd_reader_t *ctx, struct AD Dir, char *FileName,
uint8_t *cached_dir_base = NULL, *cached_dir;
uint32_t dir_lba;
struct AD tmpICB;
- int ret;
+ ssize_t ret;
/* Scan dir for ICB of file */
lbnum = partition->Start + Dir.Location;
@@ -589,7 +589,7 @@ static int UDFScanDir( dvd_reader_t *ctx, struct AD Dir, char *FileName,
cached_dir_base = NULL;
cached_dir = NULL;
if( ret < 0 )
- return ret;
+ return 0;
}
/*
if(cached_dir) {
@@ -674,6 +674,9 @@ static int UDFScanDir( dvd_reader_t *ctx, struct AD Dir, char *FileName,
}
+/**
+ * Return 1 on success, 0 or a negative read error on error.
+ */
static int UDFGetAVDP( dvd_reader_t *ctx,
struct avdp_t *avdp)
{
@@ -684,7 +687,7 @@ static int UDFGetAVDP( dvd_reader_t *ctx,
uint32_t lastsector;
int terminate;
struct avdp_t;
- int ret;
+ ssize_t ret;
if(GetUDFCache(ctx, AVDPCache, 0, avdp))
return 1;
@@ -697,9 +700,9 @@ static int UDFGetAVDP( dvd_reader_t *ctx,
for(;;) {
ret = DVDReadLBUDF( ctx, lbnum, 1, Anchor, 0 );
if( ret < 0 ) {
- return ret;
+ return (int)ret;
}
- else if( ret == 0 ) {
+ if( ret == 0 ) {
TagID = 0;
}
else {
@@ -755,10 +758,11 @@ static int UDFFindPartition( dvd_reader_t *ctx, int partnum,
uint8_t *LogBlock = (uint8_t *)(((uintptr_t)LogBlock_base & ~((uintptr_t)2047)) + 2048);
uint32_t lbnum, MVDS_location, MVDS_length;
uint16_t TagID;
- int i, volvalid, ret;
+ int i, volvalid;
+ ssize_t ret;
struct avdp_t avdp;
- if(!UDFGetAVDP(ctx, &avdp))
+ if(UDFGetAVDP(ctx, &avdp) <= 0)
return 0;
/* Main volume descriptor */
@@ -775,9 +779,9 @@ static int UDFFindPartition( dvd_reader_t *ctx, int partnum,
ret = DVDReadLBUDF( ctx, lbnum++, 1, LogBlock, 0 );
if( ret < 0 ) {
- return ret;
+ return 0;
}
- else if( ret == 0 ) {
+ if( ret == 0 ) {
TagID = 0;
}
else {
@@ -823,7 +827,7 @@ uint32_t UDFFindFile( dvd_reader_t *ctx, const char *filename,
struct AD RootICB, File, ICB;
char tokenline[ MAX_UDF_FILE_NAME_LEN ];
uint8_t filetype;
- int ret;
+ ssize_t ret;
*filesize = 0;
tokenline[0] = '\0';
@@ -841,9 +845,9 @@ uint32_t UDFFindFile( dvd_reader_t *ctx, const char *filename,
do {
ret = DVDReadLBUDF( ctx, lbnum++, 1, LogBlock, 0 );
if( ret < 0 ) {
- return ret;
+ return 0;
}
- else if( ret == 0 ) {
+ if( ret == 0 ) {
TagID = 0;
}
else {
@@ -893,8 +897,7 @@ uint32_t UDFFindFile( dvd_reader_t *ctx, const char *filename,
/* Hack to not return partition.Start for empty files. */
if( !File.Location )
return 0;
- else
- return partition.Start + File.Location;
+ return partition.Start + File.Location;
}
@@ -911,13 +914,14 @@ static int UDFGetDescriptor( dvd_reader_t *ctx, int id,
uint32_t lbnum, MVDS_location, MVDS_length;
struct avdp_t avdp;
uint16_t TagID;
- int i, desc_found = 0, ret;
+ int i, desc_found = 0;
+ ssize_t ret;
/* Find Anchor */
lbnum = 256; /* Try #1, prime anchor */
if(bufsize < DVD_VIDEO_LB_LEN)
return 0;
- if(!UDFGetAVDP(ctx, &avdp))
+ if(UDFGetAVDP(ctx, &avdp) <= 0)
return 0;
/* Main volume descriptor */
@@ -931,9 +935,9 @@ static int UDFGetDescriptor( dvd_reader_t *ctx, int id,
do {
ret = DVDReadLBUDF( ctx, lbnum++, 1, descriptor, 0 );
if( ret < 0 ) {
- return ret;
+ return 0;
}
- else if( ret == 0 ) {
+ if( ret == 0 ) {
TagID = 0;
}
else {
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/2282d093189306fed19c4f2afc07ae29cd5527fb...918878e0458fd254763ce72ec8ff1609e89b572d
--
View it on GitLab: https://code.videolan.org/videolan/libdvdread/-/compare/2282d093189306fed19c4f2afc07ae29cd5527fb...918878e0458fd254763ce72ec8ff1609e89b572d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the libdvdnav-devel
mailing list