# adl\_adDelete returns -22 !?

**URL:** <https://forum.sierrawireless.com/t/adl-addelete-returns-22/702>\
**Category:** Open AT\
**Created:** [September 19, 2006, 11:47pm UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702 "2006-09-19T23:47:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 19, 2006, 11:47pm UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702/1 "2006-09-19T23:47:27Z")

</div>

```auto
cellHandle = adl_adSubscribe ( 0, ADL_AD_SIZE_UNDEF ); // returns OK; ie, 0

result = adl_adDelete( cellHandle ); // returns -22 !!??
```

What does -22 mean ?! 😮

It is not documented! 😠

---

<div class="post-metadata">

**Author:** ![milan\_va](https://avatars.discourse-cdn.com/v4/letter/m/9fc29f/32.png) [@milan\_va](https://forum.sierrawireless.com/u/milan_va)\
**Post date:** [September 20, 2006, 1:53pm UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702/2 "2006-09-20T13:53:47Z")

</div>

I was having the same problem but luckily I’ve found this FAQ:  
[wavecom.com/modules/movie/sc … OS%3A+APIs](http://www.wavecom.com/modules/movie/scenes/support/index.php?fuseAction=listFaqs&rootName=Open+AT%AE+OS%3A+APIs)  
There, you can see:  
Q: Is there a workaround to solve -22 (ADL\_AD\_RET\_ERROR) being returned from various A&D related APIs (except adl\_adSubscribe())?

A: The error -22 (ADL\_AD\_RET\_ERROR) indicates that the A&D storage volume has become corrupt. The workaround to solve this problem is as follows:  
i. Subscribe to an A&D storage cell of undefined size.  
ii. Without writing anything to the cell, finalize the cell (using adl\_adFinalise () API). The return value of this API is not relevant.  
iii. Unsubscribe from the subscribed cell.  
iv. Call adl\_adRecompact () API to Recompact the A&D storage volume.  
v. From now onwards, all the A&D related procedures will work fine.

And it worked indeed 😛

```auto
void commRecompactFinished(void) { }

void Kill22()
 {
  s32 res, fcellh;
  fcellh=adl_adSubscribe(0x100, ADL_AD_SIZE_UNDEF);
  if (fcellh>=0)
   {
    res=adl_adFinalise(fcellh);
    res=adl_adUnsubscribe(fcellh);
    res=adl_adRecompact(commRecompactFinished);
   }
 }
```

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 20, 2006, 2:12pm UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702/3 "2006-09-20T14:12:59Z")

</div>

So why isn’t this documented in the ADL User Guide?? 😠

The last recorded change to adl\_ad.h is April 2005, and the ADL User Guide for Open-AT v3.03 is dated December 2005 - so even if it was a brand new definition, that should still have allowed plenty of time to get it into the manual! 😠😠

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [September 27, 2006, 12:24pm UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702/4 "2006-09-27T12:24:16Z")

</div>

I’ve just realised that I was missing something in the ADL User Guide:

After calling adl\_adDelete, the Cell ID does not become available for use again until after the next Recompact.

I think I was probably re-using the Cell ID before a Recompact… 😊

This does, however, beg the question of why the adl\_adSubscribe call didn’t give any error… 😒

And there’s still no excuse for the error -22 (ADL\_AD\_RET\_ERROR) being undocumented. 😠

---

<div class="post-metadata">

**Author:** ![awneil](https://avatars.discourse-cdn.com/v4/letter/a/49beb7/32.png) [@awneil](https://forum.sierrawireless.com/u/awneil)\
**Post date:** [March 6, 2007, 11:03am UTC](https://forum.sierrawireless.com/t/adl-addelete-returns-22/702/5 "2007-03-06T11:03:12Z")

</div>

> [@I](#):
>
> I think I was probably re-using the Cell ID before a Recompact… 😊

However, even after fixing this, I have still seen this problem (ADL\_AD\_RET\_ERROR results) occuring.

Note that re-initialising the A&D Volume by calling adl\_adFormat does not recover from this situation! 😠

When the A&D Storage Volume is suffering from this bug, I see adl\_adFormat returning -8 (ADL\_RET\_ERR\_BAD\_STATE) - ie, it thinks there’s a subscribed cell.
